<?php
global $_W,$_GPC;
$settings = $this->module['config'];
$o = $_GPC["o"];
$openid = trim($_GPC["openid"]);
$user = pdo_get($this->modulename . "_user", array("openid" => trim($_GPC["openid"]), "uniacid" => $_W["uniacid"]));
if(!$user['unionid']){
	$fans = pdo_get("mc_mapping_fans", array("openid" => $openid));
	$unionid = $fans['unionid'];
}else{
	$unionid = $user['unionid'];
}
if($o == "setting" || $o == "ad" || $o == "waimaidaohang" || $o == "waimailist" || $o == "goods" || $o == "movielist" || $o == "movieaddress" || $o == "page"  || $o == "pageA" || $o == "moviecity" || $o == "movietabbar"){
}else{
	if(!$openid){
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => 'SUCCESS', 'data' => $data)));
	}
}


switch ($o) {
	
	case "meituan_url":
		$appid_type = intval($_GPC["appid_type"]);//1为外卖2为商超
		if($settings['system_type'] == 1){
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
			//获取美团推广链接
			
			if($settings['meituan_api_type'] == 1){
				if($appid_type == 1){
					if(!intval($settings["meituan_waimai_h5_url"])){$settings['meituan_waimai_h5_url'] = 2;}
					$params = array('actId' => $settings['meituan_waimai_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'linkType' => 4,'sign' => 1);
					$meituansign = $this->genSign($params,$settings['meituanapikey']);
					$res = file_get_contents('https://runion.meituan.com/generateLink?actId='.$settings['meituan_waimai_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&linkType=4&sign='.$meituansign);
					if($settings['errorcodeid'] == 1){
						var_dump($res);
					}
					$res = json_decode($res,true);
					if($res['status'] == 0){
						$mtwm_url = $res['data'];
					}
					$backdata = array('mtwm_url' =>$mtwm_url);
				}elseif($appid_type == 2){
					if(!intval($settings["meituan_sc_h5_url"])){$settings['meituan_waimai_h5_url'] = 4;}
					$params = array('actId' => $settings['meituan_sc_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'linkType' => 4,'sign' => 1);
					$meituansign = $this->genSign($params,$settings['meituanapikey']);
					$res = file_get_contents('https://runion.meituan.com/generateLink?actId='.$settings['meituan_sc_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&linkType=4&sign='.$meituansign);
					if($settings['errorcodeid'] == 2){
						var_dump($res);
					}
					$res = json_decode($res,true);
					if($res['status'] == 0){
						$mtsc_url = $res['data'];
					}
					$backdata = array('mtsc_url' => $mtsc_url);
				}
			}else{
				$postdata = http_build_query(array('apikey' => $settings['ddxapikey'],'sid' => $user['uid'],'generate_we_app' => true,'qrcode' => true));
				$options = array(
						'http' => array(
						'method' => 'POST',
						'header' => 'Content-type:application/x-www-form-urlencoded',
						'content' => $postdata,
						'timeout' => 1 * 60 // 超时时间（单位:s）
					  )
					);
				$cxContext = stream_context_create($options);
				if($appid_type == 1){
					//外卖
					$wm = file_get_contents("http://api.tbk.dingdanxia.com/waimai/meituan_privilege", false, $cxContext);
					if($settings['errorcodeid'] == 3){
						var_dump($wm);
					}
					$wm = json_decode($wm,true);
					if($wm['code'] == 200){
						$mtwm_url = $wm['data']['we_app_info']['page_path'];
						$mtwm_h5 = $wm['data']['h5_evoke'];
					}else{
						$mtwm_url = '';
						$mtwm_h5 = '';
					}
					$backdata = array('mtwm_url' =>$mtwm_url,'mtwm_qrcode' =>$mtwm_qrcode,'mtwm_h5' =>$mtwm_h5);
				}elseif($appid_type == 2){
					//闪购
					$wm = file_get_contents("http://api.tbk.dingdanxia.com/waimai/meituan_sg_privilege", false, $cxContext);
					if($settings['errorcodeid'] == 4){
						var_dump($wm);
					}
					$wm = json_decode($wm,true);
					if($wm['code'] == 200){
						$mtsc_url = $wm['data']['we_app_info']['page_path'];
						$mtsc_h5 = $wm['data']['h5_evoke'];
					}else{
						$mtsc_url = '';
						$mtsc_h5 = '';
					}
					$backdata = array('mtsc_url' => $mtsc_url,'mtsc_qrcode' =>$mtsc_qrcode,'mtsc_h5' =>$mtsc_h5);
				}
			}
			
			//获取美团推广链接
		}else{
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
			//获取美团推广链接
			if($settings['meituan_api_type'] == 1){
				if($appid_type == 1){
					if(!intval($settings["meituan_waimai_h5_url"])){$settings['meituan_waimai_h5_url'] = 2;}
					$params = array('actId' => $settings['meituan_waimai_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'linkType' => 4,'sign' => 1);
					$meituansign = $this->genSign($params,$settings['meituanapikey']);
					$res = file_get_contents('https://runion.meituan.com/generateLink?actId='.$settings['meituan_waimai_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&linkType=4&sign='.$meituansign);
					if($settings['errorcodeid'] == 5){
						var_dump($res);
					}
					$res = json_decode($res,true);
					if($res['status'] == 0){
						$mtwm_url = $res['data'];
					}
					$backdata = array('mtwm_url' =>$mtwm_url);
				}elseif($appid_type == 2){
					if(!intval($settings["meituan_sc_h5_url"])){$settings['meituan_sc_h5_url'] = 4;}
					$params = array('actId' => $settings['meituan_sc_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'linkType' => 4,'sign' => 1);
					$meituansign = $this->genSign($params,$settings['meituanapikey']);
					$res = file_get_contents('https://runion.meituan.com/generateLink?actId='.$settings['meituan_sc_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&linkType=4&sign='.$meituansign);
					if($settings['errorcodeid'] == 6){
						var_dump($res);
					}
					$res = json_decode($res,true);
					if($res['status'] == 0){
						$mtsc_url = $res['data'];
					}
					$backdata = array('mtsc_url' => $mtsc_url);
				}
			}else{
				$postdata = http_build_query(array('apikey' => $settings['ddxapikey'],'sid' => $user['uid'],'generate_we_app' => true,'qrcode' => true));
				$options = array(
						'http' => array(
						'method' => 'POST',
						'header' => 'Content-type:application/x-www-form-urlencoded',
						'content' => $postdata,
						'timeout' => 1 * 60 // 超时时间（单位:s）
					  )
					);
				$cxContext = stream_context_create($options);
				if($appid_type == 1){
					//外卖
					$wm = file_get_contents("http://api.tbk.dingdanxia.com/waimai/meituan_privilege", false, $cxContext);
					if($settings['errorcodeid'] == 7){
						var_dump($wm);
					}
					$wm = json_decode($wm,true);
					if($wm['code'] == 200){
						$mtwm_url = $wm['data']['we_app_info']['page_path'];
						$mtwm_h5 = $wm['data']['h5_evoke'];
					}else{
						$mtwm_url = '';
						$mtwm_h5 = '';
					}
					$backdata = array('mtwm_url' =>$mtwm_url,'mtwm_qrcode' =>$mtwm_qrcode,'mtwm_h5' =>$mtwm_h5);
				}elseif($appid_type == 2){
					//闪购
					$wm = file_get_contents("http://api.tbk.dingdanxia.com/waimai/meituan_sg_privilege", false, $cxContext);
					if($settings['errorcodeid'] == 8){
						var_dump($wm);
					}
					$wm = json_decode($wm,true);
					if($wm['code'] == 200){
						$mtsc_url = $wm['data']['we_app_info']['page_path'];
						$mtsc_h5 = $wm['data']['h5_evoke'];
					}else{
						$mtsc_url = '';
						$mtsc_h5 = '';
					}
					$backdata = array('mtsc_url' => $mtsc_url,'mtsc_qrcode' =>$mtsc_qrcode,'mtsc_h5' =>$mtsc_h5);
				}
			}
			
			//获取美团推广链接
		}
		
		
		
		$ret = json_encode($backdata);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "chkpid":
		if($settings['elm_api_type'] == 0 || !$settings['elm_api_type'] || $settings['elm_api_type'] === NULL){
		    if($settings['system_type'] == 1){
				$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
				if(!$user['relation_id']){
					$pid = pdo_get($this->modulename . "_pid_u", array("unionid" => $unionid,"is_use" => 1, "system_id" => $settings['system_id']));
					if($pid){
						$pid_use_time = $pid['use_time'];
					}else{
						$pid_use_time = 0;
					}
				}else{
					$pid_use_time = 0;
				}
			}else{
				$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
				if(!$user['relation_id']){
					$pid = pdo_get($this->modulename . "_pid", array("openid" => $openid,"is_use" => 1, "uniacid" => $_W["uniacid"]));
					if($pid){
						$pid_use_time = $pid['use_time'];
					}else{
						$pid_use_time = 0;
					}
				}else{
					$pid_use_time = 0;
				}
			}
	    }elseif($settings['elm_api_type'] == 1){
			$pid_use_time = 0;
		}
		$ret = $pid_use_time;
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "updatepid":
		if($settings['elm_api_type'] == 0 || !$settings['elm_api_type'] || $settings['elm_api_type'] === NULL){
		    if($settings['system_type'] == 1){
				$pid = pdo_get($this->modulename . "_pid_u", array("unionid" => $unionid,"is_use" => 1, "system_id" => $settings['system_id']));
				if($pid){
					pdo_update($this->modulename . "_pid_u", array("update_time" => time()), array("id" => $pid['id']));
				}
			}else{
				$pid = pdo_get($this->modulename . "_pid", array("openid" => $openid,"is_use" => 1, "uniacid" => $_W["uniacid"]));
				if($pid){
					pdo_update($this->modulename . "_pid", array("update_time" => time()), array("id" => $pid['id']));
				}
			}
	    }elseif($settings['elm_api_type'] == 1){
            $pid_use_time = 0;
		}
		$ret = $pid_use_time;
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "subscribemessage":
		$type = intval($_GPC["type"]);//1为订餐提醒，2为检查次数
	    
		$warn_tplid = array();
		if($settings['warn_yhq_tplid']){array_push($warn_tplid,$settings['warn_yhq_tplid']);}
		if($settings['warn_hy_tplid']){array_push($warn_tplid,$settings['warn_hy_tplid']);}
		if($settings['warn_order_tplid']){array_push($warn_tplid,$settings['warn_order_tplid']);}

		foreach($warn_tplid as $k=>$v){
			$sub = [];
			$sub = pdo_get($this->modulename . "_subscribemessage", array("unionid" => $v, "openid" => $openid, "uniacid" => $_W["uniacid"]));
			if(!empty($sub)){
				if($type == 2){
					$last_time = date("Y-m-d", $sub["warm_daytime"]);
					if ($last_time == date("Y-m-d")) {
						$warm_daynum = $sub["warm_daynum"];
					} else {
						$warm_daynum = 0;
					}
				}else{
					$last_time = date("Y-m-d", $sub["warm_daytime"]);
					if ($last_time == date("Y-m-d")) {
						$warm_daynum = $sub["warm_daynum"] + 1;
						$warm_daytime = $sub["warm_daytime"];
					} else {
						$warm_daynum = 1;
						$warm_daytime = time();
					}
					pdo_update($this->modulename . "_subscribemessage", array("s_1_num +=" => 1,"warm_daytime" => $warm_daytime,"warm_daynum" => $warm_daynum), array("id" => $sub['id'], "uniacid" => $_W["uniacid"]));
				}
			}else{
				if($type == 2){
					$warm_daynum = 0;
				}else{
					pdo_insert($this->modulename . "_subscribemessage", array("adid" => $user['uid'],"unionid" => $v,"s_1_num" => 1,"warm_daytime" => time(),"warm_daynum" => 1, "openid" => $openid, "uniacid" => $_W["uniacid"], "create_time" => time()));
					$warm_daynum = 1;
				}
			}
		}

		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'warm_daynum' => $warm_daynum)));
	    
	case "gzh_poster":
		$appid_type = intval($_GPC["type"]);//0为外卖1为商超
		if($settings['system_type'] == 1){
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
			if(!$user['relation_id']){
				$pid = pdo_get($this->modulename . "_pid_u", array("unionid" => $unionid,"is_use" => 1, "system_id" => $settings['system_id']));
				if($pid){
					$pid_use_time = $pid['use_time'];
				}else{
					$pid_use_time = 0;
				}
			}else{
				$pid_use_time = 0;
			}
		}else{
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
			if(!$user['relation_id']){
				$pid = pdo_get($this->modulename . "_pid", array("openid" => $openid,"is_use" => 1, "uniacid" => $_W["uniacid"]));
				if($pid){
					$pid_use_time = $pid['use_time'];
				}else{
					$pid_use_time = 0;
				}
			}else{
				$pid_use_time = 0;
			}
		}
		
		$ret = $pid_use_time;
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "gettaobaoauth":
		$appid_type = intval($_GPC["appid_type"]);//3为外卖4为商超
		$elmwm_act_id = trim($_GPC["elmwm_act_id"]);
		if($settings['elm_api_type'] == 0 || !$settings['elm_api_type'] || $settings['elm_api_type'] === NULL){
			if($settings['system_type'] == 1){
				//查询是否有pid空闲
				$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
				if($user['relation_id']){//如果用户已经绑定渠道id，则使用渠道id
					$relation_id = $user['relation_id'];
					$pid = explode("_",$settings['tbqudaopid']);
					if($appid_type == 3){
						if($elmwm_act_id){
							$settings['elmwm_promotion_scene_id'] = $elmwm_act_id;
						}else{
							if(!$settings['elmwm_promotion_scene_id']){
								$settings['elmwm_promotion_scene_id'] = '1571715733668';
							}
						}
						$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
						if($settings['errorcodeid'] == 9){
							var_dump($elmwm_url);
						}
						if($elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
							$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
						}else{
							$backdata = array('elmwm_url' =>'','elmwm_qrcode' =>'','elmwm_h5' =>'','is_qudao' =>1,'pid_time' =>$pid_use_time);
						}
					}elseif($appid_type == 4){
						if(!$settings['elmsc_promotion_scene_id']){$settings['elmsc_promotion_scene_id'] = '1585018034441';}
						$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
						if($settings['errorcodeid'] == 10){
							var_dump($elmsc_url);
						}
						if($elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
							$backdata = array('elmsc_url' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
						}else{
							$backdata = array('elmsc_url' =>'','elmsc_qrcode' =>'','elmsc_h5' =>'','is_qudao' =>1,'pid_time' =>$pid_use_time);
						}
					}
					$ret = json_encode($backdata);
					$data = array();
					$data["key"] = substr(md5(time() . uniqid()), 0, 16);
					$data["data"] = $this->aesEn($ret, $data["key"]);
					exit(json_encode(array('code' => 0, 'status' => 2, 'msg' => 'SUCCESS', 'data' => $data)));
				}else{//如果没有绑定渠道id，则使用pid
					$pid = pdo_get($this->modulename . "_pid_u", array("unionid" => $unionid,"is_use" => 1, "system_id" => $settings['system_id']));
					if($pid){$pid_use_time = $pid['use_time'];}
					elseif(!$pid){
						$pid = pdo_get($this->modulename . "_pid_u", array("is_use" => 0, "system_id" => $settings['system_id']));
						$pid_use_time = time();
					}
					//有pid空闲
					if($pid){
						pdo_update($this->modulename . "_pid_u", array("nickname" => $user['nickname'],"openid" => $openid,"unionid" => $user['unionid'],"uid" => $user['user_id'],"is_use" => 1,"use_time" => $pid_use_time,"update_time" => time()), array("id" => $pid['id']));
						pdo_insert($this->modulename . "_pidlog", array("uniacid" => $_W["uniacid"],"pid" => $pid['pid'],"sid" => $pid['sid'],"rid" => $pid['rid'],"nickname" => $user['nickname'],"openid" => $openid,"unionid" => $user['unionid'],"uid" => $user['user_id'],"is_use" => 1,"use_time" => $pid_use_time,"update_time" => time(), "system_id" => $settings['system_id']));
						$pid_array = explode("_",$pid['pid']);
						if($appid_type == 3){
							if($elmwm_act_id){
								$settings['elmwm_promotion_scene_id'] = $elmwm_act_id;
							}else{
								if(!$settings['elmwm_promotion_scene_id']){
									$settings['elmwm_promotion_scene_id'] = '1571715733668';
								}
							}
							if($pid['rid']){
								$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&relation_id='.$pid['rid'].'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
								if($settings['errorcodeid'] == 11){
									var_dump($elmwm_url);
								}
							}else{
								$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?appkey='.$settings['appkey'].'&sid='.$pid['sid'].'&adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&platform=2'),true);
								if($settings['errorcodeid'] == 12){
									var_dump($elmwm_url);
								}
							}
							if($elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
								
								$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
							}else{
								$backdata = array('elmwm_url' =>'','elmwm_qrcode' =>'','elmwm_h5' =>'','is_qudao' =>0,'pid_time' =>$pid_use_time);
							}
						}elseif($appid_type == 4){
							if(!$settings['elmsc_promotion_scene_id']){$settings['elmsc_promotion_scene_id'] = '1585018034441';}
							if($pid['rid']){
								$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&relation_id='.$pid['rid'].'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
								if($settings['errorcodeid'] == 13){
									var_dump($elmsc_url);
								}
							}else{
								$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?appkey='.$settings['appkey'].'&sid='.$pid['sid'].'&adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&platform=2'),true);
								if($settings['errorcodeid'] == 14){
									var_dump($elmsc_url);
								}
							}
							if($elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
								$backdata = array('elmsc_url' => $elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>0,'pid_time' =>$pid_use_time);
							}else{
								$backdata = array('elmsc_url' => '','elmsc_qrcode' =>'','elmsc_h5' =>'','is_qudao' =>0,'pid_time' =>$pid_use_time);
							}
						}
						$ret = json_encode($backdata);
						$data = array();
						$data["key"] = substr(md5(time() . uniqid()), 0, 16);
						$data["data"] = $this->aesEn($ret, $data["key"]);
						exit(json_encode(array('code' => 0, 'status' => 2, 'msg' => 'SUCCESS', 'data' => $data)));
					}else{//没有pid空闲，则使用渠道
						$inviter_code = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_sc_invitecode_get.ashx?appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&relation_app=common&code_type=1'),true);
						if($settings['errorcodeid'] == 15){
							var_dump($inviter_code);
						}
						$inviter_code = $inviter_code['tbk_sc_invitecode_get_response']['data']['inviter_code'];
						$qudao_url = 'https://mos.m.taobao.com/inviter/register?inviterCode='.$inviter_code.'&src=pub&app=common&rtag='.$user['uid'].'A'.time();

						$tkl = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_tkl_create.ashx?appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&url='.urlencode($qudao_url)),true);
						if($settings['errorcodeid'] == 16){
							var_dump($tkl);
						}
						if($tkl['status'] == 200){
							$qudaotkl = $tkl['model'];
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => '3&#55357;&#56392;'.$qudaotkl.'打开手机淘宝或点击链接 https://m.tb.cn/h.aaaaaaa 至浏览器[渠道方备案完成后，可为您进行商品/店铺和更多物料的推广]')));
						}else{
							exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '获取渠道信息错误')));
						}
					}
				}
			}else{
				//查询是否有pid空闲
				$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
				if($user['relation_id']){//如果用户已经绑定渠道id，则使用渠道id
					$relation_id = $user['relation_id'];
					$pid = explode("_",$settings['tbqudaopid']);
					if($appid_type == 3){
						if($elmwm_act_id){
							$settings['elmwm_promotion_scene_id'] = $elmwm_act_id;
						}else{
							if(!$settings['elmwm_promotion_scene_id']){
								$settings['elmwm_promotion_scene_id'] = '1571715733668';
							}
						}
						$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
						if($settings['errorcodeid'] == 17){
							var_dump($elmwm_url);
						}
						if($elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
							$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
						}else{
							$backdata = array('elmwm_url' =>'','elmwm_qrcode' =>'','elmwm_h5' =>'','is_qudao' =>1,'pid_time' =>$pid_use_time);
						}
					}elseif($appid_type == 4){
						if(!$settings['elmsc_promotion_scene_id']){$settings['elmsc_promotion_scene_id'] = '1585018034441';}
						$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
						if($settings['errorcodeid'] == 18){
							var_dump($elmsc_url);
						}
						if($elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
							$backdata = array('elmsc_url' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
						}else{
							$backdata = array('elmsc_url' =>'','elmsc_qrcode' =>'','elmsc_h5' =>'','is_qudao' =>1,'pid_time' =>$pid_use_time);
						}
					}
					$ret = json_encode($backdata);
					$data = array();
					$data["key"] = substr(md5(time() . uniqid()), 0, 16);
					$data["data"] = $this->aesEn($ret, $data["key"]);
					exit(json_encode(array('code' => 0, 'status' => 2, 'msg' => 'SUCCESS', 'data' => $data)));
				}else{//如果没有绑定渠道id，则使用pid
					$pid = pdo_get($this->modulename . "_pid", array("openid" => $openid,"is_use" => 1, "uniacid" => $_W["uniacid"]));
					if($pid){$pid_use_time = $pid['use_time'];}
					elseif(!$pid){
						$pid = pdo_get($this->modulename . "_pid", array("is_use" => 0, "uniacid" => $_W["uniacid"]));
						$pid_use_time = time();
					}
					//有pid空闲
					if($pid){
						pdo_update($this->modulename . "_pid", array("nickname" => $user['nickname'],"openid" => $openid,"unionid" => $user['unionid'],"uid" => $user['user_id'],"is_use" => 1,"use_time" => $pid_use_time,"update_time" => time()), array("id" => $pid['id']));
						pdo_insert($this->modulename . "_pidlog", array("uniacid" => $_W["uniacid"],"pid" => $pid['pid'],"sid" => $pid['sid'],"rid" => $pid['rid'],"nickname" => $user['nickname'],"openid" => $openid,"unionid" => $user['unionid'],"uid" => $user['user_id'],"is_use" => 1,"use_time" => $pid_use_time,"update_time" => time(), "system_id" => $settings['system_id']));
						$pid_array = explode("_",$pid['pid']);
						if($appid_type == 3){
							if($elmwm_act_id){
								$settings['elmwm_promotion_scene_id'] = $elmwm_act_id;
							}else{
								if(!$settings['elmwm_promotion_scene_id']){
									$settings['elmwm_promotion_scene_id'] = '1571715733668';
								}
							}
							if($pid['rid']){
								$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&relation_id='.$pid['rid'].'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
								if($settings['errorcodeid'] == 19){
									var_dump($elmwm_url);
								}
							}else{
								$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?appkey='.$settings['appkey'].'&sid='.$pid['sid'].'&adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&platform=2'),true);
								if($settings['errorcodeid'] == 20){
									var_dump($elmwm_url);
								}
							}
							if($elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
								
								$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
							}else{
								$backdata = array('elmwm_url' =>'','elmwm_qrcode' =>'','elmwm_h5' =>'','is_qudao' =>0,'pid_time' =>$pid_use_time);
							}
						}elseif($appid_type == 4){
							if(!$settings['elmsc_promotion_scene_id']){$settings['elmsc_promotion_scene_id'] = '1585018034441';}
							if($pid['rid']){
								$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&relation_id='.$pid['rid'].'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
								if($settings['errorcodeid'] == 21){
									var_dump($elmsc_url);
								}
							}else{
								$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?appkey='.$settings['appkey'].'&sid='.$pid['sid'].'&adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&platform=2'),true);
								if($settings['errorcodeid'] == 22){
									var_dump($elmsc_url);
								}
							}
							if($elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
								$backdata = array('elmsc_url' => $elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>0,'pid_time' =>$pid_use_time);
							}else{
								$backdata = array('elmsc_url' => '','elmsc_qrcode' =>'','elmsc_h5' =>'','is_qudao' =>0,'pid_time' =>$pid_use_time);
							}
						}
						$ret = json_encode($backdata);
						$data = array();
						$data["key"] = substr(md5(time() . uniqid()), 0, 16);
						$data["data"] = $this->aesEn($ret, $data["key"]);
						exit(json_encode(array('code' => 0, 'status' => 2, 'msg' => 'SUCCESS', 'data' => $data)));
					}else{//没有pid空闲，则使用渠道
						$inviter_code = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_sc_invitecode_get.ashx?appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&relation_app=common&code_type=1'),true);
						if($settings['errorcodeid'] == 23){
							var_dump($inviter_code);
						}
						$inviter_code = $inviter_code['tbk_sc_invitecode_get_response']['data']['inviter_code'];
						$qudao_url = 'https://mos.m.taobao.com/inviter/register?inviterCode='.$inviter_code.'&src=pub&app=common&rtag='.$user['uid'].'A'.time();

						$tkl = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_tkl_create.ashx?appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&url='.urlencode($qudao_url)),true);
						if($settings['errorcodeid'] == 24){
							var_dump($tkl);
						}
						if($tkl['status'] == 200){
							$qudaotkl = $tkl['model'];
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => '3&#55357;&#56392;'.$qudaotkl.'打开&#55357;&#56393;淘bao&#55357;&#56392;或点击链接 https://m.tb.cn/h.aaaaaaa 至浏览器[渠道方备案完成后，可为您进行商品/店铺和更多物料的推广]')));
						}else{
							exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '获取渠道信息错误')));
						}
					}
				}
			}
		}elseif($settings['elm_api_type'] == 1){
			if($appid_type == 3){
				if($settings['elmwm_promotion_scene_id_jutuike'] > 0){
					$actid = $settings['elmwm_promotion_scene_id_jutuike'];
				}else{
					$actid = 3;
				}
			}elseif($appid_type == 4){
				if($settings['elmsc_promotion_scene_id_jutuike'] > 0){
					$actid = $settings['elmsc_promotion_scene_id_jutuike'];
				}else{
					$actid = 5;
				}
			}
			if($settings['system_type'] == 1){
				$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
			}else{
				$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
			}
			$res = json_decode(file_get_contents('http://api.jutuike.com/union/act?relation_flag_name=waimaixia&apikey='.$settings['jutuikeapikey'].'&act_id='.$actid.'&sid='.$user['uid']),true);
			if ($res['code'] == 1) {
				if($appid_type == 3){
					$backdata = array('elmwm_url' =>$res['data']['we_app_info']['page_path'],'elmwm_qrcode' =>$res['data']['we_app_info']['miniCode'],'elmwm_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$res['data']['h5'],'is_qudao' =>0,'pid_time' =>0 );
				}elseif($appid_type == 4){
					$backdata = array('elmsc_url' => $res['data']['we_app_info']['page_path'],'elmsc_qrcode' =>$res['data']['we_app_info']['miniCode'],'elmsc_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$res['data']['h5'],'is_qudao' =>0,'pid_time' =>0);
				}
				$ret = json_encode($backdata);
				$data = array();
				$data["key"] = substr(md5(time() . uniqid()), 0, 16);
				$data["data"] = $this->aesEn($ret, $data["key"]);
				exit(json_encode(array('code' => 0, 'status' => 2, 'msg' => 'SUCCESS', 'data' => $data)));
			} else {
				exit(json_encode($res));
			}
		}
	case "taobaoauth_done":
		$appid_type = intval($_GPC["appid_type"]);//3为外卖4为商超
		$elmwm_act_id = trim($_GPC["elmwm_act_id"]);
		if($settings['system_type'] == 1){
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
			if($user['relation_id']){
				$relation_id = $user['relation_id'];
				$pid = explode("_",$settings['tbqudaopid']);
				if($appid_type == 3){
					if($elmwm_act_id){
						$settings['elmwm_promotion_scene_id'] = $elmwm_act_id;
					}else{
						if(!$settings['elmwm_promotion_scene_id']){
							$settings['elmwm_promotion_scene_id'] = '1571715733668';
						}
					}
					$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
					if($settings['errorcodeid'] == 25){
						var_dump($elmwm_url);
					}
					if($elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
						
						$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
					}else{
						$backdata = array('elmwm_url' =>'','elmwm_qrcode' =>'','elmwm_h5' =>'','is_qudao' =>0,'pid_time' =>$pid_use_time);
					}
				}elseif($appid_type == 4){
					if(!$settings['elmsc_promotion_scene_id']){$settings['elmsc_promotion_scene_id'] = '1585018034441';}
					$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
					if($settings['errorcodeid'] == 26){
						var_dump($elmsc_url);
					}
					if($elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
						$backdata = array('elmsc_url' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>0,'pid_time' =>$pid_use_time );
					}else{
						$backdata = array('elmsc_url' =>'','elmsc_qrcode' =>'','elmsc_h5' =>'','is_qudao' =>0,'pid_time' =>$pid_use_time);
					}
				}
				$ret = json_encode($backdata);
				$data = array();
				$data["key"] = substr(md5(time() . uniqid()), 0, 16);
				$data["data"] = $this->aesEn($ret, $data["key"]);
				exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
			}else{
				$content = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_sc_publisher_get.ashx?relation_app=common&info_type=1&page_no=1&page_size=50&appkey='.$settings['appkey'].'&sid='.$settings['sid']),true);
				if($settings['errorcodeid'] == 27){
					var_dump($content);
				}
				foreach($content['tbk_sc_publisher_info_get_response']['data']['inviter_list']['map_data'] as $k=>$v){
					if($v['rtag']){
						$v['rtag'] = explode("A",$v['rtag'])[0];
						if($v['rtag'] == $user['uid']){
							pdo_update($this->modulename . "_user_u", array("relation_id" => $v['relation_id']), array("unionid" => $unionid));
							$relation_id = $v['relation_id'];
							$pid = explode("_",$settings['tbqudaopid']);
							if($appid_type == 3){
								if($elmwm_act_id){
									$settings['elmwm_promotion_scene_id'] = $elmwm_act_id;
								}else{
									if(!$settings['elmwm_promotion_scene_id']){
										$settings['elmwm_promotion_scene_id'] = '1571715733668';
									}
								}
								$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
								if($settings['errorcodeid'] == 28){
									var_dump($elmwm_url);
								}
								
								if($elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
									$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
								}else{
									$backdata = array('elmwm_url' =>'','elmwm_qrcode' =>'','elmwm_h5' =>'','is_qudao' =>1,'pid_time' =>$pid_use_time);
								}
							}elseif($appid_type == 4){
								if(!$settings['elmsc_promotion_scene_id']){$settings['elmsc_promotion_scene_id'] = '1585018034441';}
								$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
								if($settings['errorcodeid'] == 29){
									var_dump($elmsc_url);
								}
								if($elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
									$backdata = array('elmsc_url' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
								}else{
									$backdata = array('elmsc_url' =>'','elmsc_qrcode' =>'','elmsc_h5' =>'','is_qudao' =>1,'pid_time' =>$pid_use_time);
								}
							}
							$ret = json_encode($backdata);
							$data = array();
							$data["key"] = substr(md5(time() . uniqid()), 0, 16);
							$data["data"] = $this->aesEn($ret, $data["key"]);
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
						}
					}
				}
				exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => 'ERROR')));
			}
		}else{
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
			if($user['relation_id']){
				$relation_id = $user['relation_id'];
				$pid = explode("_",$settings['tbqudaopid']);
				if($appid_type == 3){
					if($elmwm_act_id){
						$settings['elmwm_promotion_scene_id'] = $elmwm_act_id;
					}else{
						if(!$settings['elmwm_promotion_scene_id']){
							$settings['elmwm_promotion_scene_id'] = '1571715733668';
						}
					}
					$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
					if($settings['errorcodeid'] == 29){
						var_dump($elmwm_url);
					}
					if($elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
						
						$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
					}else{
						$backdata = array('elmwm_url' =>'','elmwm_qrcode' =>'','elmwm_h5' =>'','is_qudao' =>0,'pid_time' =>$pid_use_time);
					}
				}elseif($appid_type == 4){
					if(!$settings['elmsc_promotion_scene_id']){$settings['elmsc_promotion_scene_id'] = '1585018034441';}
					$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
					if($settings['errorcodeid'] == 30){
						var_dump($elmsc_url);
					}
					if($elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
						$backdata = array('elmsc_url' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>0,'pid_time' =>$pid_use_time );
					}else{
						$backdata = array('elmsc_url' =>'','elmsc_qrcode' =>'','elmsc_h5' =>'','is_qudao' =>0,'pid_time' =>$pid_use_time);
					}
				}
				$ret = json_encode($backdata);
				$data = array();
				$data["key"] = substr(md5(time() . uniqid()), 0, 16);
				$data["data"] = $this->aesEn($ret, $data["key"]);
				exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
			}else{
				$content = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_sc_publisher_get.ashx?relation_app=common&info_type=1&page_no=1&page_size=50&appkey='.$settings['appkey'].'&sid='.$settings['sid']),true);
				if($settings['errorcodeid'] == 31){
					var_dump($content);
				}
				foreach($content['tbk_sc_publisher_info_get_response']['data']['inviter_list']['map_data'] as $k=>$v){
					if($v['rtag']){
						$v['rtag'] = explode("A",$v['rtag'])[0];
						if($v['rtag'] == $user['uid']){
							pdo_update($this->modulename . "_user", array("relation_id" => $v['relation_id']), array("openid" => $openid));
							if($user['unionid']){
								pdo_update($this->modulename . "_user", array("relation_id" => $v['relation_id']), array("unionid" => $user['unionid']));
							}
							if($settings['system_type'] == 1 && $user['unionid']){
								pdo_update($this->modulename . "_user_u", array("relation_id" => $v['relation_id']), array("unionid" => $user['unionid']));
							}
							$relation_id = $v['relation_id'];
							$pid = explode("_",$settings['tbqudaopid']);
							if($appid_type == 3){
								if($elmwm_act_id){
									$settings['elmwm_promotion_scene_id'] = $elmwm_act_id;
								}else{
									if(!$settings['elmwm_promotion_scene_id']){
										$settings['elmwm_promotion_scene_id'] = '1571715733668';
									}
								}
								$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);

								if($settings['errorcodeid'] == 32){
									var_dump($elmwm_url);
								}
								
								if($elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
									$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
								}else{
									$backdata = array('elmwm_url' =>'','elmwm_qrcode' =>'','elmwm_h5' =>'','is_qudao' =>1,'pid_time' =>$pid_use_time);
								}
							}elseif($appid_type == 4){
								if(!$settings['elmsc_promotion_scene_id']){$settings['elmsc_promotion_scene_id'] = '1585018034441';}
								$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
								if($settings['errorcodeid'] == 33){
									var_dump($elmsc_url);
								}
								if($elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
									$backdata = array('elmsc_url' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
								}else{
									$backdata = array('elmsc_url' =>'','elmsc_qrcode' =>'','elmsc_h5' =>'','is_qudao' =>1,'pid_time' =>$pid_use_time);
								}
							}
							$ret = json_encode($backdata);
							$data = array();
							$data["key"] = substr(md5(time() . uniqid()), 0, 16);
							$data["data"] = $this->aesEn($ret, $data["key"]);
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
						}
					}
				}
				exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => 'ERROR')));
			}
		}
		
	
	case "userinfo":
		$invite_uid = intval($_GPC["invite_uid"]);
		if(!$invite_uid){$invite_uid = 0;}
		$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
		if($settings['system_type'] == 1){
			$invite_user = pdo_get($this->modulename . "_user_u", array("user_id" => $invite_uid, "system_id" => $settings['system_id']));
			$invite_user1 = pdo_get($this->modulename . "_user", array("unionid" => $invite_user['unionid'], "uniacid" => $_W["uniacid"]));
		}else{
			$invite_user = pdo_get($this->modulename . "_user", array("user_id" => $invite_uid, "uniacid" => $_W["uniacid"]));
			$invite_user1 = $invite_user;
		}
		if(!$invite_user){
			$parent_id = 0;
			$invite_uid = '0';
			$parent_unionid = 0;
			$invite_unionid = '0';
		}else{
			$parent_id = $invite_user['uid'];
			$invite_uid = $invite_user['invite_uid'].'_'.$invite_user['uid'];
			$parent_unionid = $invite_user['unionid'];
			if(empty($invite_user['invite_unionid'])){$invite_user['invite_unionid'] = '0';}
			$invite_unionid = $invite_user['invite_unionid'].'#'.$invite_user['unionid'];
		}
		if (empty($user)) {
			$data = array();
			if($settings['system_type'] == 1){
				$last_user = pdo_fetchall("SELECT uid FROM ".tablename($this->modulename . "_user")." where uid > 0 and system_id = {$settings['system_id']} order by uid desc limit 1");
			}else{
				$last_user = pdo_fetchall("SELECT uid FROM ".tablename($this->modulename . "_user")." where uniacid = ".$_W["uniacid"]." and uid > 0 order by uid desc limit 1");
			}
			
			if(!$last_user){
				if(intval($settings['uid']) == 0){$settings['uid'] = 16800000;}
				$data['uid'] = $settings['uid'] + 1;
			}else{
				$data['uid'] = $last_user[0]['uid'] + 1;
			}
			$data["uniacid"] = $_W["uniacid"];
			$data["system_id"] = $settings['system_id'];
			$data["openid"] = $openid;
			$data["parent_id"] = $parent_id;
			$data["invite_uid"] = $invite_uid;
			$data["parent_unionid"] = $parent_unionid;
			$data["invite_unionid"] = $invite_unionid;
			$data["unionid"] = $unionid;
			$data["new"] = 1;
			$data["create_time"] = $_W["timestamp"];
			pdo_insert($this->modulename . "_user", $data);
			$user_id = pdo_insertid();
			if($settings['system_type'] == 1 && $unionid){
				$user_u = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings["system_id"]));
				if(!$user_u){
					$user_uu = pdo_get($this->modulename . "_user_u", array("uid" => $data['uid'], "system_id" => $settings["system_id"]));
					if($user_uu && $user_uu['unionid'] != $unionid){
						$last_user = pdo_fetchall("SELECT uid FROM ".tablename($this->modulename . "_user")." where uid > 0 and system_id = {$settings['system_id']} order by uid desc limit 1");
						if(!$last_user){
							if(intval($settings['uid']) == 0){$settings['uid'] = 16800000;}
							$data['uid'] = $settings['uid'] + 1;
						}else{
							$data['uid'] = $last_user[0]['uid'] + 1;
						}
						pdo_update($this->modulename . "_user", array("uid" => $data['uid']), array("openid" => $openid));
					}
					pdo_insert($this->modulename . "_user_u", $data);
					$user_id = pdo_insertid();
				}
			}
			
			if($invite_user && $settings['system_type'] == 1){
				$wechats = pdo_get("account_wechats", array("uniacid" => $invite_user["uniacid"]));
				if($wechats){
					$this->newuserNotify($invite_user['openid'],$data['uid']);
				}else{
					$fans_unionid = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($fans_unionid){
						$this->newuserNotify($fans_unionid['openid'],$data['uid']);
					}
				}
			}
			if($invite_user1 && $invite_user1['s_1_num'] > 0){
				$res = $this->xcxnewuserNotify($invite_user1['openid'],$data['uid']);
			}
			if($invite_user){
				if($settings['system_type'] == 1){
					pdo_update($this->modulename . "_user_u", array('invite_sum +=' => 1), array("user_id" => $invite_user["user_id"]));
				}else{
					pdo_update($this->modulename . "_user", array('invite_sum +=' => 1), array("user_id" => $invite_user["user_id"]));
				}
			}
			$user_id = $user['user_id'];
		}else{
			if($_GPC["code"] && $_GPC["iv"] && $_GPC["encryptedData"]){
				$code = $_GPC["code"];
				$appid = $_W["account"]["key"];
				$secret = $_W["account"]["secret"];
				$iv = $_GPC["iv"];
				$encryptedData = $_GPC["encryptedData"];
				$api = "https://api.weixin.qq.com/sns/jscode2session?appid={$appid}&secret={$secret}&js_code={$code}&grant_type=authorization_code";
				$res = ihttp_get($api);
				$result = json_decode($res["content"], true);
				$mobile = "";
				$openid = $result["openid"];
				include_once '../addons/'.$this->modulename.'/lib/wxBizDataCrypt.php';
				$wxBizDataCrypt = new WXBizDataCrypt($appid, $result["session_key"]);
				$errCode = $wxBizDataCrypt->decryptData($encryptedData, $iv, $data);
				if($settings['errorcodeid'] == 34){
					var_dump($errCode);
				}
				if ($errCode == 0) {
					$data = json_decode($data, true);
					$mobile = $data["phoneNumber"];
					if(!$mobile){
						$data['nickName'] = $this->filterEmoji($data['nickName']);
						if(!$data['nickName']){$data['nickName'] = '用户'.mt_rand(111111,999999);}
						pdo_update($this->modulename . "_user", array("unionid" => $data['unionId'],"nickname" => $data['nickName'],"avatar" => $data['avatarUrl']), array("user_id" => $user["user_id"]));
						$user_id = $user['user_id'];
						if($settings['system_type'] == 1){
							if($unionid){
								$data['unionId'] = $unionid;
								$user_u = pdo_get($this->modulename . "_user_u", array("unionid" => $data['unionId'], "system_id" => $settings["system_id"]));
								if($user_u){
									pdo_update($this->modulename . "_user_u", array("unionid" => $data['unionId'],"nickname" => $data['nickName'],"avatar" => $data['avatarUrl']), array("user_id" => $user_u["user_id"]));
									$user_id = $user_u['user_id'];
								}else{
									$user_uu = pdo_get($this->modulename . "_user_u", array("uid" => $user['uid'], "system_id" => $settings["system_id"]));
									if($user_uu && $user_uu['unionid'] != $data['unionId']){
										$last_user = pdo_fetchall("SELECT uid FROM ".tablename($this->modulename . "_user")." where uid > 0 and system_id = {$settings['system_id']} order by uid desc limit 1");
										if(!$last_user){
											if(intval($settings['uid']) == 0){$settings['uid'] = 16800000;}
											$user['uid'] = $settings['uid'] + 1;
										}else{
											$user['uid'] = $last_user[0]['uid'] + 1;
										}
										pdo_update($this->modulename . "_user", array("uid" => $user['uid']), array("openid" => $openid));
									}
									unset($user["user_id"]);
									$user["unionid"] = $data['unionId'];
									$user["nickname"] = $data['nickName'];
									$user["avatar"] = $data['avatarUrl'];
									pdo_insert($this->modulename . "_user_u", $user);
									$user_id = pdo_insertid();
								}
							}
							
						}else{
							$user["unionid"] = $unionid;
							$user["nickname"] = $data['nickName'];
							$user["avatar"] = $data['avatarUrl'];
						}
					}
					
					
				}
				
			}else{
				if($unionid && !$user['unionid']){
					pdo_update($this->modulename . "_user", array("unionid" => $unionid), array("user_id" => $user["user_id"]));
					$user['unionid'] = $unionid;
				}
				if($settings['system_type'] == 1 && $unionid){
					$user_u = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings["system_id"]));
					if(!$user_u){
						$user_uu = pdo_get($this->modulename . "_user_u", array("uid" => $user['uid'], "system_id" => $settings["system_id"]));
						if($user_uu && $user_uu['unionid'] != $unionid){
							$last_user = pdo_fetchall("SELECT uid FROM ".tablename($this->modulename . "_user")." where uid > 0 and system_id = {$settings['system_id']} order by uid desc limit 1");
							if(!$last_user){
								if(intval($settings['uid']) == 0){$settings['uid'] = 16800000;}
								$user['uid'] = $settings['uid'] + 1;
							}else{
								$user['uid'] = $last_user[0]['uid'] + 1;
							}
							pdo_update($this->modulename . "_user", array("uid" => $user['uid']), array("openid" => $openid));
						}
						unset($user["user_id"]);
						pdo_insert($this->modulename . "_user_u", $user);
						$user_id = pdo_insertid();
					}
				}
			}
		}
		if($settings['system_type'] == 1){
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings["system_id"]));
			if(!$user['s_1_num']){$user['s_1_num'] = '0';}
			if(!$user['uid']){$user['uid'] = '请登录';}
			$user_pid = pdo_get($this->modulename . "_pid_u", array("unionid" => $fans['unionid'], "system_id" => $settings['system_id']));
		}else{
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
			if(!$user['s_1_num']){$user['s_1_num'] = '0';}
			if(!$user['uid']){$user['uid'] = '请登录';}
			$user['follow'] = 0;
			$user_pid = pdo_get($this->modulename . "_pid", array("uid" => $user['user_id'], "uniacid" => $_W["uniacid"]));
		}
		

		if($user['is_tuan'] == 0){
			$user['userleveltext'] = $settings['member_name'];
		}elseif($user['is_tuan'] == 1){
			$user['userleveltext'] = $settings['tuan_name'];
		}elseif($user['is_tuan'] == 2){
			$user['userleveltext'] = $settings['he_name'];
		}
		if($user['foodlist']){
			$user['foodlist'] = explode(",",$user['foodlist']);
		}else{
			$user['foodlist'] = array();
		}

		$timeToday = mktime("0", "0", "0", date("m"), date("d"), date("y"));
		$time = time();
		if ($user["sign_in"]) {
			$lastdiff = $user["sign_in"] - $timeToday;
			if ($lastdiff < -86400) {
				$sign_count = 0;
				$sum = 0;
				$user["sign_in_continuity"] = 0;
				$user["sign_in_sum"] = 0;
				$UserInfoData = array("sign_in_continuity" => $sign_count, "sign_in_sum" => $sum);
				if($settings['system_type'] == 1){
					pdo_update($this->modulename . "_user_u", $UserInfoData, array("unionid" => $unionid, "system_id" => $settings['system_id']));
				}else{
					pdo_update($this->modulename . "_user", $UserInfoData, array("openid" => $openid, "uniacid" => $_W["uniacid"]));
				}
			}
		}
		if($settings['system_type'] == 1){
			$RecordId = pdo_get($this->modulename . "_task_temp", array("unionid" => $user["unionid"], "type" => 3, "system_id" => $settings['system_id']), array("id", "addtime"));
		}else{
			$RecordId = pdo_get($this->modulename . "_task_temp", array("openid" => $user["openid"], "type" => 3, "uniacid" => $_W["uniacid"]), array("id", "addtime"));
		}
		
		$last_time = date("Y-m-d", $RecordId["addtime"]);
		if ($last_time == date("Y-m-d")) {
			$user["User_watch"] = 1;
		} else {
			$user["User_watch"] = 2;
		}

		
		$backdata = array("openid" => $openid, "userinfo" => $user, "mobile" => $mobile, "pid_time" => $user_pid['use_time']);
		$ret = json_encode($backdata);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "setting":
		$settings['static_domain'] = $_W['siteroot'];
		$settings['sharethumb'] = tomedia($settings['sharethumb']);
		$settings['feeds_thumb'] = tomedia($settings['feeds_thumb']);
		$settings['dianwo'] = tomedia($settings['dianwo']);
		$settings['waimai_guidepic'] = tomedia($settings['waimai_guidepic']);
		$settings['index_fullLoading_logoUrl'] = tomedia($settings['index_fullLoading_logoUrl']);
		$settings['waimaitt_meituanwm_toppic'] = tomedia($settings['waimaitt_meituanwm_toppic']);
		$settings['waimaitt_meituansc_toppic'] = tomedia($settings['waimaitt_meituansc_toppic']);
		$settings['waimaitt_meituanwm_step1pic'] = tomedia($settings['waimaitt_meituanwm_step1pic']);
		$settings['waimaitt_meituanwm_step2pic'] = tomedia($settings['waimaitt_meituanwm_step2pic']);
		$settings['waimaitt_meituanwm_step3pic'] = tomedia($settings['waimaitt_meituanwm_step3pic']);
		$settings['waimaitt_meituanwm_step4pic'] = tomedia($settings['waimaitt_meituanwm_step4pic']);
		$settings['waimaitt_meituansc_step1pic'] = tomedia($settings['waimaitt_meituansc_step1pic']);
		$settings['waimaitt_meituansc_step2pic'] = tomedia($settings['waimaitt_meituansc_step2pic']);
		$settings['waimaitt_meituansc_step3pic'] = tomedia($settings['waimaitt_meituansc_step3pic']);
		$settings['waimaitt_meituansc_step4pic'] = tomedia($settings['waimaitt_meituansc_step4pic']);
		$settings['waimaitt_meituanwm_poster'] = tomedia($settings['waimaitt_meituanwm_poster']);
		$settings['waimaitt_meituansc_poster'] = tomedia($settings['waimaitt_meituansc_poster']);
		$settings['waimaitt_elmwm_poster'] = tomedia($settings['waimaitt_elmwm_poster']);
		$settings['waimaitt_elmsc_poster'] = tomedia($settings['waimaitt_elmsc_poster']);
		$settings['waimaitt_tools_addpic'] = tomedia($settings['waimaitt_tools_addpic']);
		$settings['waimaitt_tools_sharepic'] = tomedia($settings['waimaitt_tools_sharepic']);
		$settings['waimainew_tools_addpic'] = tomedia($settings['waimainew_tools_addpic']);
		$settings['waimainew_tools_sharepic'] = tomedia($settings['waimainew_tools_sharepic']);
		$settings['ranking_toppic'] = tomedia($settings['ranking_toppic']);
		$settings['myposter'] = tomedia($settings['myposter']);
		$settings['login_pic'] = tomedia($settings['login_pic']);
		$settings['taobaoauth_pic'] = tomedia($settings['taobaoauth_pic']);
		$settings['warn_pic'] = tomedia($settings['warn_pic']);
		$settings['eatwhat_bgpic'] = tomedia($settings['eatwhat_bgpic']);
		$settings['waimaitt_leftpic'] = tomedia($settings['waimaitt_leftpic']);
		$settings['waimaitt_midpic'] = tomedia($settings['waimaitt_midpic']);
		$settings['waimaitt_rightpic'] = tomedia($settings['waimaitt_rightpic']);
		$settings['waimai_leftpic'] = tomedia($settings['waimai_leftpic']);
		$settings['waimai_midpic'] = tomedia($settings['waimai_midpic']);
		$settings['waimai_rightpic'] = tomedia($settings['waimai_rightpic']);
		$settings['waimainew_leftpic'] = tomedia($settings['waimainew_leftpic']);
		$settings['waimainew_midpic'] = tomedia($settings['waimainew_midpic']);
		$settings['waimainew_rightpic'] = tomedia($settings['waimainew_rightpic']);
		$settings['eatwhat_sharethumb'] = tomedia($settings['eatwhat_sharethumb']);
		$settings['eatwhat_foodlist'] = explode(",",$settings['eatwhat_foodlist']);
		$settings['waimaitt_elmwm_toppic'] = tomedia($settings['waimaitt_elmwm_toppic']);
		$settings['waimaitt_elmsc_toppic'] = tomedia($settings['waimaitt_elmsc_toppic']);
		$settings['movie_kefupic'] = tomedia($settings['movie_kefupic']);
		$settings['waimaitt_elmwm_step1pic'] = tomedia($settings['waimaitt_elmwm_step1pic']);
		$settings['waimaitt_elmwm_step2pic'] = tomedia($settings['waimaitt_elmwm_step2pic']);
		$settings['waimaitt_elmwm_step3pic'] = tomedia($settings['waimaitt_elmwm_step3pic']);
		$settings['waimaitt_elmwm_step4pic'] = tomedia($settings['waimaitt_elmwm_step4pic']);
		$settings['waimaitt_elmsc_step1pic'] = tomedia($settings['waimaitt_elmsc_step1pic']);
		$settings['waimaitt_elmsc_step2pic'] = tomedia($settings['waimaitt_elmsc_step2pic']);
		$settings['waimaitt_elmsc_step3pic'] = tomedia($settings['waimaitt_elmsc_step3pic']);
		$settings['waimaitt_elmsc_step4pic'] = tomedia($settings['waimaitt_elmsc_step4pic']);
		$settings['waimai_elmwm_step1pic'] = tomedia($settings['waimai_elmwm_step1pic']);
		$settings['waimai_elmwm_step2pic'] = tomedia($settings['waimai_elmwm_step2pic']);
		$settings['waimai_elmwm_step3pic'] = tomedia($settings['waimai_elmwm_step3pic']);
		$settings['waimainew_elmwm_step1pic'] = tomedia($settings['waimainew_elmwm_step1pic']);
		$settings['waimainew_elmwm_step2pic'] = tomedia($settings['waimainew_elmwm_step2pic']);
		$settings['waimainew_elmwm_step3pic'] = tomedia($settings['waimainew_elmwm_step3pic']);

		$settings['user_bgpic'] = tomedia($settings['user_bgpic']);

		if($settings['user_order_text'] === NULL){$settings['user_order_text'] = '订单中心';}
		if($settings['user_fans_text'] === NULL){$settings['user_fans_text'] = '粉丝中心';}
		if($settings['user_tools_text'] === NULL){$settings['user_tools_text'] = '常用工具';}

		$settings['user_movie_order_pic'] = tomedia($settings['user_movie_order_pic']);
		if($settings['user_movie_order_text'] === NULL){$settings['user_movie_order_text'] = '电影票订单';}

		$settings['user_credit_order_pic'] = tomedia($settings['user_credit_order_pic']);
		if($settings['user_credit_order_text'] === NULL){$settings['user_credit_order_text'] = '商品订单';}

		$settings['user_my_order_pic'] = tomedia($settings['user_my_order_pic']);
		if($settings['user_my_order_text'] === NULL){$settings['user_my_order_text'] = '我的订单';}

		$settings['user_fans_order_pic'] = tomedia($settings['user_fans_order_pic']);
		if($settings['user_fans_order_text'] === NULL){$settings['user_fans_order_text'] = '粉丝订单';}

		$settings['user_find_order_pic'] = tomedia($settings['user_find_order_pic']);
		if($settings['user_find_order_text'] === NULL){$settings['user_find_order_text'] = '订单找回';}

		$settings['user_fans_zhiyao_pic'] = tomedia($settings['user_fans_zhiyao_pic']);
		if($settings['user_fans_zhiyao_text'] === NULL){$settings['user_fans_zhiyao_text'] = '直邀粉丝';}

		$settings['user_fans_other_pic'] = tomedia($settings['user_fans_other_pic']);
		if($settings['user_fans_other_text'] === NULL){$settings['user_fans_other_text'] = '其他粉丝';}

		$settings['user_fans_poster_pic'] = tomedia($settings['user_fans_poster_pic']);
		if($settings['user_fans_poster_text'] === NULL){$settings['user_fans_poster_text'] = '邀请海报';}

		$settings['user_fans_ranking_pic'] = tomedia($settings['user_fans_ranking_pic']);
		if($settings['user_fans_ranking_text'] === NULL){$settings['user_fans_ranking_text'] = '排行榜';}


		if($settings['warn_tpl_daynum'] === NULL){$settings['warn_tpl_daynum'] = 2;}
		if($settings['income_type'] === NULL){$settings['income_type'] = 0;}
		if($settings['user_income_type'] === NULL){$settings['user_income_type'] = 0;}
		if($settings['user_order_center'] === NULL){$settings['user_order_center'] = 1;}
		if($settings['user_my_order'] === NULL){$settings['user_my_order'] = 1;}
		if($settings['user_fans_order'] === NULL){$settings['user_fans_order'] = 1;}
		if($settings['user_find_order'] === NULL){$settings['user_find_order'] = 1;}
		if($settings['user_fans_center'] === NULL){$settings['user_fans_center'] = 1;}
		if($settings['user_fans_zhiyao'] === NULL){$settings['user_fans_zhiyao'] = 1;}
		if($settings['user_fans_other'] === NULL){$settings['user_fans_other'] = 1;}
		if($settings['user_fans_poster'] === NULL){$settings['user_fans_poster'] = 1;}
		if($settings['user_fans_ranking'] === NULL){$settings['user_fans_ranking'] = 1;}
		if($settings['login_type'] === NULL){$settings['login_type'] = 1;}
		if($settings['index_type'] === NULL){$settings['index_type'] = 2;}
		if($settings['waimai_is_tools'] === NULL){$settings['waimai_is_tools'] = 1;}
		if($settings['waimaitt_is_tools'] === NULL){$settings['waimaitt_is_tools'] = 1;}
		if($settings['waimainew_is_tools'] === NULL){$settings['waimainew_is_tools'] = 1;}

		if($settings['meituan_page_type'] === NULL){$settings['meituan_page_type'] = 0;}
		if($settings['elm_page_type'] === NULL){$settings['elm_page_type'] = 0;}

		if($settings['index_is_credit'] === NULL){$settings['index_is_credit'] = 1;}
		if($settings['index_is_credit'] === NULL){$settings['index_is_credit'] = 1;}
		if($settings['waimaitt_is_oldtools'] === NULL && $settings['waimaitt_is_tools'] == 0){$settings['waimaitt_is_oldtools'] = 1;}
		if($settings['waimaitt_is_oldtools'] === NULL && $settings['waimaitt_is_tools'] == 1){$settings['waimaitt_is_oldtools'] = 0;}
		if($settings['waimainew_is_oldtools'] === NULL && $settings['waimainew_is_tools'] == 0){$settings['waimainew_is_oldtools'] = 1;}
		if($settings['waimainew_is_oldtools'] === NULL && $settings['waimainew_is_tools'] == 1){$settings['waimainew_is_oldtools'] = 0;}
		if($settings['index_is_movie'] === NULL){$settings['index_is_movie'] = 1;}
		if($settings['index_is_comemovie'] === NULL){$settings['index_is_comemovie'] = 1;}
		if($settings['index_is_credit'] === NULL){$settings['index_is_credit'] = 1;}
		if($settings['user_movie_order'] === NULL){$settings['user_movie_order'] = 1;}
		if($settings['user_credit_order'] === NULL){$settings['user_credit_order'] = 1;}

		if($settings['movie_tabbar_isindex'] === NULL){$settings['movie_tabbar_isindex'] = 0;}

		if($settings['index_type_movie'] === NULL){$settings['index_type_movie'] = 0;}

		
		if($settings['index_type'] == 3 && $settings['waimaitt_is_oldtools'] ==1){
			$settings['waimaitt_lunbobannerxbgcolor'] = $settings['waimaitt_tools_bgcolor'];
		}elseif($settings['index_type'] == 3){
			$settings['waimaitt_lunbobannerxbgcolor'] = $settings['waimaitt_bgcolor'];
		}

		if($settings['index_type'] == 2){
			$settings['waimaitt_navigationBarBackgroundColor'] = $settings['waimai_navigationBarBackgroundColor'];
			$settings['waimaitt_navigationBarTextStyle'] = $settings['waimai_navigationBarTextStyle'];
			$settings['waimaitt_navigationBarTitleText'] = $settings['waimai_navigationBarTitleText'];
			$settings['waimaitt_bgcolor'] = $settings['waimai_bgcolor'];
			$settings['waimaitt_daohang_bgcolor'] = $settings['waimai_bgcolor'];
			$settings['waimaitt_lunbobgcolor'] = $settings['waimai_bgcolor'];
			$settings['waimaitt_lunbobannerxbgcolor'] = $settings['waimai_bgcolor'];
			$settings['waimaitt_lunbo_width'] = $settings['lunbo_width'];
			$settings['waimaitt_lunbo_height'] = $settings['lunbo_height'];
			$settings['waimaitt_lunbo_borderRadius'] = $settings['lunbo_borderRadius'];
			$settings['waimaitt_lunbo_spacing'] = $settings['lunbo_spacing'];
			$settings['waimaitt_lunbo_padding'] = $settings['lunbo_padding'];
			$settings['waimaitt_lunbo_indicatorType'] = $settings['lunbo_indicatorType'];
			$settings['waimaitt_daohang_border_radius'] = $settings['daohang_border_radius'];
			$settings['waimaitt_daohang_width'] = $settings['daohang_width'];
			$settings['waimaitt_daohang_iconwidth'] = $settings['daohang_iconwidth'];
			$settings['waimaitt_daohang_iconheight'] = $settings['daohang_iconheight'];
			$settings['waimaitt_daohang_box_shadow_bgcolor'] = $settings['daohang_box_shadow_bgcolor'];
			$settings['waimaitt_daohang_box_shadow'] = $settings['daohang_box_shadow'];
			$settings['waimaitt_daohang_textsize'] = $settings['daohang_textsize'];
			$settings['waimaitt_daohang_textcolor'] = $settings['daohang_textcolor'];
			$settings['waimaitt_is_tools'] = $settings['waimai_is_tools'];
		}
		if($settings['index_type'] == 4){
			$settings['waimaitt_is_tools'] = $settings['waimainew_is_tools'];
			$settings['waimaitt_navigationBarBackgroundColor'] = $settings['waimainew_navigationBarBackgroundColor'];
			$settings['waimaitt_navigationBarTextStyle'] = $settings['waimainew_navigationBarTextStyle'];
			$settings['waimaitt_navigationBarTitleText'] = $settings['waimainew_navigationBarTitleText'];
			$settings['waimaitt_bgcolor'] = $settings['waimainew_bgcolor'];
			$settings['waimaitt_daohang_bgcolor'] = $settings['waimainew_bgcolor'];
			$settings['waimaitt_lunbobgcolor'] = $settings['waimainew_bgcolor'];
			$settings['waimaitt_lunbobannerxbgcolor'] = $settings['waimainew_bgcolor'];
			$settings['waimaitt_lunbo_width'] = $settings['waimainew_lunbo_width'];
			$settings['waimaitt_lunbo_height'] = $settings['waimainew_lunbo_height'];
			$settings['waimaitt_lunbo_borderRadius'] = $settings['waimainew_lunbo_borderRadius'];
			$settings['waimaitt_lunbo_spacing'] = $settings['waimainew_lunbo_spacing'];
			$settings['waimaitt_lunbo_padding'] = $settings['waimainew_lunbo_padding'];
			$settings['waimaitt_lunbo_indicatorType'] = $settings['waimainew_lunbo_indicatorType'];
			$settings['waimaitt_daohang_border_radius'] = $settings['waimainew_daohang_border_radius'];
			$settings['waimaitt_daohang_width'] = $settings['waimainew_daohang_width'];
			$settings['waimaitt_daohang_iconwidth'] = $settings['waimainew_daohang_iconwidth'];
			$settings['waimaitt_daohang_iconheight'] = $settings['waimainew_daohang_iconheight'];
			$settings['waimaitt_daohang_box_shadow_bgcolor'] = $settings['waimainew_daohang_box_shadow_bgcolor'];
			$settings['waimaitt_daohang_box_shadow'] = $settings['waimainew_daohang_box_shadow'];
			$settings['waimaitt_daohang_textsize'] = $settings['waimainew_daohang_textsize'];
			$settings['waimaitt_daohang_textcolor'] = $settings['waimainew_daohang_textcolor'];
		}
		if($settings['index_type_movie'] == 1){$settings['waimaitt_bgcolor'] = '#FFFFFF';}
		if($settings['waimaitt_lunbo_indicatorType'] === NULL){$settings['waimaitt_lunbo_indicatorType'] = 'dot';}

		$settings['indextype'] = 3;

		if(strpos($settings['meituan_page_url'],'http') !== false){ 
		   $settings['meituan_page_url_type'] = 1;
		}else{
		   $settings['meituan_page_url_type'] = 2;
		}
		if(strpos($settings['elm_page_url'],'http') !== false){ 
		   $settings['elm_page_url_type'] = 1;
		}else{
		   $settings['elm_page_url_type'] = 2;
		}

		$settings['warn_tplid'] = array();
		if($settings['warn_yhq_tplid']){array_push($settings['warn_tplid'],$settings['warn_yhq_tplid']);}
		if($settings['warn_hy_tplid']){array_push($settings['warn_tplid'],$settings['warn_hy_tplid']);}
		if($settings['warn_order_tplid']){array_push($settings['warn_tplid'],$settings['warn_order_tplid']);}
		$settings['movie_tplid'] = array($settings['movie_tpl_1'],$settings['movie_tpl_2']);
		$settings['item_tplid'] = array($settings['item_tplid']);
		
		unset($settings['xbapikey']);
		unset($settings['meituangroup_AppKey']);
        unset($settings['meituangroup_utmSource']);
		unset($settings['appkey']);
		unset($settings['tbqudaopid']);
		unset($settings['apikey']);
		unset($settings['ddxapikey']);
		unset($settings['meituanapikey']);
		unset($settings['meituanappkey']);

		unset($settings['movie_api_s_appKey']);
		unset($settings['movie_api_s_appSecret']);
		unset($settings['movie_api_s_url']);
		unset($settings['movie_api_notifyUrl']);

		unset($settings['pid_black']);
		
		$backdata = array("setting" => $settings);
		$ret = json_encode($backdata);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "tasknum":
		if($settings['system_type'] == 1){
			$openid2 = 'unionid';
			$openid1 = $unionid;
			$uniacid = 'system_id';
			$uniacid1 = $settings['system_id'];
			$UserInfo = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
		}else{
			$openid2 = 'openid';
			$openid1 = $openid;
			$uniacid = 'uniacid';
			$uniacid1 = $_W["uniacid"];
			$UserInfo = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
		}
		if($settings['system_type'] == 1){
			$total = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_task") . " where system_id = {$settings['system_id']} AND (user_type = {$UserInfo['is_tuan']} OR user_type = 99) AND  is_online = 1  AND  status = 1 AND start_time <= ".time()." AND end_time >= ".time()." ORDER BY displayorder DESC");
		}else{
			$total = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_task") . " where uniacid = {$_W['uniacid']} AND (user_type = {$UserInfo['is_tuan']} OR user_type = 99) AND  is_online = 1 AND  status = 1 AND start_time <= ".time()." AND end_time >= ".time()." ORDER BY displayorder DESC");
		}
		$donetask = 0;
		foreach($total as $vvv){
			if($vvv['is_retask'] <= 1 && $vvv['task_type'] == 0){
				$user_task_list = pdo_fetchall("SELECT count(*) as num FROM " . tablename($this->modulename."_user_task") . " WHERE ".$openid2." = '{$openid1}' and task_id = ".$vvv['task_id']." AND status = 1 AND ".$uniacid." = ".$uniacid1);
				if($vvv['is_retask'] == 0){$vvv['re_num'] = 1;}
				if($user_task_list[0]['num'] >= $vvv['re_num']){
					$donetask += 1;
				}
			}
		}
		$tasknum = count($total) - $donetask;
		$backdata = array('tasknum' => $tasknum);
		$ret = json_encode($backdata);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "edit_userinfo":
		$realname = trim($_GPC["realname"]);
		$mobile = trim($_GPC["mobile"]);
		$alipayno = trim($_GPC["alipayno"]);
		if($settings['system_type'] == 1){
			$res = pdo_update($this->modulename . "_user_u", array("realname" => $realname,"mobile" => $mobile,"alipayno" => $alipayno), array("unionid" => $unionid, "system_id" => $settings['system_id']));
			$res = pdo_update($this->modulename . "_user", array("realname" => $realname,"mobile" => $mobile,"alipayno" => $alipayno), array("openid" => $openid, "uniacid" => $_W["uniacid"]));
		}else{
			$res = pdo_update($this->modulename . "_user", array("realname" => $realname,"mobile" => $mobile,"alipayno" => $alipayno), array("openid" => $openid, "uniacid" => $_W["uniacid"]));
		}
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => $res)));
	case "addfoodlist":
		$foodlist = trim($_GPC["foodlist"]);
		$arr = "奸|射|乳|内|幼|妻|逼|光|交|B|b|凤|换|换|阿扁推翻|阿宾|阿賓|挨了一炮|爱液横流|安街逆|安局办公楼|安局豪华|安门事|安眠藥|案的准确|八九民|八九学|八九政治|把病人整|把邓小平|把学生整|罢工门|白黄牙签|败培训|办本科|办理本科|办理各种|办理票据|办理文凭|办理真实|办理证书|办理资格|办文凭|办怔|办证|半刺刀|辦毕业|辦證|谤罪获刑|磅解码器|磅遥控器|宝在甘肃修|保过答案|报复执法|爆发骚|北省委门|被打死|被指抄袭|被中共|本公司担|本无码|毕业證|变牌绝|辩词与梦|冰毒|冰火毒|冰火佳|冰火九重|冰火漫|冰淫传|冰在火上|波推龙|博彩娱|博会暂停|博园区伪|不查都|不查全|不思四化|布卖淫女|部忙组阁|部是这样|才知道只生|财众科技|采花堂|踩踏事|苍山兰|苍蝇水|藏春阁|藏獨|操了嫂|操嫂子|策没有不|插屁屁|察象蚂|拆迁灭|车牌隐|成人电|成人卡通|成人聊|成人片|成人视|成人图|成人文|成人小|城管灭|惩公安|惩贪难|充气娃|冲凉死|抽着大中|抽着芙蓉|出成绩付|出售发票|出售军|穿透仪器|春水横溢|纯度白|纯度黄|次通过考|催眠水|催情粉|催情药|催情藥|挫仑|达毕业证|答案包|答案提供|打标语|打错门|打飞机专|打死经过|打死人|打砸办公|大鸡巴|大雞巴|大纪元|大揭露|大奶子|大批贪官|大肉棒|大嘴歌|代办发票|代办各|代办文|代办学|代办制|代辦|代表烦|代開|代考|代理发票|代理票据|代您考|代您考|代写毕|代写论|代孕|贷办|贷借款|贷开|戴海静|当代七整|当官要精|当官在于|党的官|党后萎|党前干劲|刀架保安|导的情人|导叫失|导人的最|导人最|导小商|到花心|得财兼|的同修|灯草和|等级證|等屁民|等人老百|等人是老|等人手术|邓爷爷转|邓玉娇|地产之歌|地下先烈|地震哥|帝国之梦|递纸死|点数优惠|电狗|电话监|电鸡|甸果敢|蝶舞按|丁香社|丁子霖|顶花心|东北独立|东复活|东京热|東京熱|洞小口紧|都当警|都当小姐|都进中央|毒蛇钻|独立台湾|赌球网|短信截|对日强硬|多美康|躲猫猫|俄羅斯|恶势力操|恶势力插|恩氟烷|儿园惨|儿园砍|儿园杀|儿园凶|二奶大|发牌绝|发票出|发票代|发票销|發票|法车仑|法伦功|法轮|法轮佛|法维权|法一轮|法院给废|法正乾|反测速雷|反雷达测|反屏蔽|范燕琼|方迷香|防电子眼|防身药水|房贷给废|仿真枪|仿真证|诽谤罪|费私服|封锁消|佛同修|夫妻交换|福尔马林|福娃的預|福娃頭上|福香巴|府包庇|府集中领|妇销魂|附送枪|复印件生|复印件制|富民穷|富婆给废|改号软件|感扑克|冈本真|肛交|肛门是邻|岡本真|钢针狗|钢珠枪|港澳博球|港馬會|港鑫華|高就在政|高考黑|高莺莺|搞媛交|告长期|告洋状|格证考试|各类考试|各类文凭|跟踪器|工程吞得|工力人|公安错打|公安网监|公开小姐|攻官小姐|共狗|共王储|狗粮|狗屁专家|鼓动一些|乖乖粉|官商勾|官也不容|官因发帖|光学真题|跪真相|滚圆大乳|国际投注|国家妓|国家软弱|国家吞得|国库折|国一九五七|國內美|哈药直销|海访民|豪圈钱|号屏蔽器|和狗交|和狗性|和狗做|黑火药的|红色恐怖|红外透视|紅色恐|胡江内斗|胡紧套|胡錦濤|胡适眼|胡耀邦|湖淫娘|虎头猎|华国锋|华门开|化学扫盲|划老公|还会吹萧|还看锦涛|环球证件|换妻|皇冠投注|黄冰|浑圆豪乳|活不起|火车也疯|机定位器|机号定|机号卫|机卡密|机屏蔽器|基本靠吼|绩过后付|激情电|激情短|激情妹|激情炮|级办理|级答案|急需嫖|集体打砸|集体腐|挤乳汁|擠乳汁|佳静安定|家一样饱|家属被打|甲虫跳|甲流了|奸成瘾|兼职上门|监听器|监听王|简易炸|江胡内斗|江太上|江系人|江贼民|疆獨|蒋彦永|叫自慰|揭贪难|姐包夜|姐服务|姐兼职|姐上门|金扎金|金钟气|津大地震|津地震|进来的罪|京地震|京要地震|经典谎言|精子射在|警察被|警察的幌|警察殴打|警察说保|警车雷达|警方包庇|警用品|径步枪|敬请忍|究生答案|九龙论坛|九评共|酒象喝汤|酒像喝汤|就爱插|就要色|举国体|巨乳|据说全民|绝食声|军长发威|军刺|军品特|军用手|开邓选|开锁工具|開碼|開票|砍杀幼|砍伤儿|康没有不|康跳楼|考答案|考后付款|考机构|考考邓|考联盟|考前答|考前答案|考前付|考设备|考试包过|考试保|考试答案|考试机构|考试联盟|考试枪|考研考中|考中答案|磕彰|克分析|克千术|克透视|空和雅典|孔摄像|控诉世博|控制媒|口手枪|骷髅死|快速办|矿难不公|拉登说|拉开水晶|来福猎|拦截器|狼全部跪|浪穴|老虎机|雷人女官|类准确答|黎阳平|李洪志|李咏曰|理各种证|理是影帝|理证件|理做帐报|力骗中央|力月西|丽媛离|利他林|连发手|聯繫電|炼大法|两岸才子|两会代|两会又三|聊视频|聊斋艳|了件渔袍|猎好帮手|猎枪销|猎槍|獵槍|领土拿|流血事|六合彩|六死|六四事|六月联盟|龙湾事件|隆手指|陆封锁|陆同修|氯胺酮|乱奸|乱伦类|乱伦小|亂倫|伦理大|伦理电影|伦理毛|伦理片|轮功|轮手枪|论文代|罗斯小姐|裸聊网|裸舞视|落霞缀|麻古|麻果配|麻果丸|麻将透|麻醉狗|麻醉枪|麻醉槍|麻醉藥|蟆叫专家|卖地财政|卖发票|卖银行卡|卖自考|漫步丝|忙爱国|猫眼工具|毛一鲜|媒体封锁|每周一死|美艳少妇|妹按摩|妹上门|门按摩|门保健|門服務|氓培训|蒙汗药|迷幻型|迷幻药|迷幻藥|迷昏口|迷昏药|迷昏藥|迷魂香|迷魂药|迷魂藥|迷奸药|迷情水|迷情药|迷藥|谜奸药|蜜穴|灭绝罪|民储害|民九亿商|民抗议|明慧网|铭记印尼|摩小姐|母乳家|木齐针|幕没有不|幕前戲|内射|南充针|嫩穴|嫩阴|泥马之歌|你的西域|拟涛哥|娘两腿之间|妞上门|浓精|怒的志愿|女被人家搞|女激情|女技师|女人和狗|女任职名|女上门|女優|鸥之歌|拍肩神药|拍肩型|牌分析|牌技网|炮的小蜜|陪考枪|配有消|喷尿|嫖俄罗|嫖鸡|平惨案|平叫到床|仆不怕饮|普通嘌|期货配|奇迹的黄|奇淫散|骑单车出|气狗|气枪|汽狗|汽枪|氣槍|铅弹|钱三字经|枪出售|枪的参|枪的分|枪的结|枪的制|枪货到|枪决女犯|枪决现场|枪模|枪手队|枪手网|枪销售|枪械制|枪子弹|强权政府|强硬发言|抢其火炬|切听器|窃听器|禽流感了|勤捞致|氢弹手|清除负面|清純壆|情聊天室|情妹妹|情视频|情自拍|氰化钾|氰化钠|请集会|请示威|请愿|琼花问|区的雷人|娶韩国|全真证|群奸暴|群起抗暴|群体性事|绕过封锁|惹的国|人权律|人体艺|人游行|人在云上|人真钱|认牌绝|任于斯国|柔胸粉|肉洞|肉棍|如厕死|乳交|软弱的国|赛后骚|三挫|三级片|三秒倒|三网友|三唑|骚妇|骚浪|骚穴|骚嘴|扫了爷爷|色电影|色妹妹|色视频|色小说|杀指南|山涉黑|煽动不明|煽动群众|上门激|烧公安局|烧瓶的|韶关斗|韶关玩|韶关旭|射网枪|涉嫌抄袭|深喉冰|神七假|神韵艺术|生被砍|生踩踏|生肖中特|圣战不息|盛行在舞|尸博|失身水|失意药|狮子旗|十八等|十大谎|十大禁|十个预言|十类人不|十七大幕|实毕业证|实体娃|实学历文|士康事件|式粉推|视解密|是躲猫|手变牌|手答案|手狗|手机跟|手机监|手机窃|手机追|手拉鸡|手木仓|手槍|守所死法|兽交|售步枪|售纯度|售单管|售弹簧刀|售防身|售狗子|售虎头|售火药|售假币|售健卫|售军用|售猎枪|售氯胺|售麻醉|售冒名|售枪支|售热武|售三棱|售手枪|售五四|售信用|售一元硬|售子弹|售左轮|书办理|熟妇|术牌具|双管立|双管平|水阎王|丝护士|丝情侣|丝袜保|丝袜恋|丝袜美|丝袜妹|丝袜网|丝足按|司长期有|司法黑|私房写真|死法分布|死要见毛|四博会|四大扯|个四小码|苏家屯集|诉讼集团|素女心|速代办|速取证|酸羟亚胺|蹋纳税|太王四神|泰兴幼|泰兴镇中|泰州幼|贪官也辛|探测狗|涛共产|涛一样胡|特工资|特码|特上门|体透视镜|替考|替人体|天朝特|天鹅之旅|天推广歌|田罢工|田田桑|田停工|庭保养|庭审直播|通钢总经|偷電器|偷肃贪|偷听器|偷偷贪|头双管|透视功能|透视镜|透视扑|透视器|透视眼镜|透视药|透视仪|秃鹰汽|突破封锁|突破网路|推油按|脱衣艳|瓦斯手|袜按摩|外透视镜|外围赌球|湾版假|万能钥匙|万人骚动|王立军|王益案|网民案|网民获刑|网民诬|微型摄像|围攻警|围攻上海|维汉员|维权基|维权人|维权谈|委坐船|谓的和谐|温家堡|温切斯特|温影帝|溫家寶|瘟加饱|瘟假饱|文凭证|文强|纹了毛|闻被控制|闻封锁|瓮安|我的西域|我搞台独|乌蝇水|无耻语录|无码专|五套功|五月天|午夜电|午夜极|武警暴|武警殴|武警已增|务员答案|务员考试|雾型迷|西藏限|西服进去|希脏|习进平|习晋平|席复活|席临终前|席指着护|洗澡死|喜贪赃|先烈纷纷|现大地震|现金投注|线透视镜|限制言|陷害案|陷害罪|相自首|香港论坛|香港马会|香港一类|香港总彩|硝化甘|小穴|校骚乱|协晃悠|写两会|泄漏的内|新建户|新疆叛|新疆限|新金瓶|新唐人|信访专班|信接收器|兴中心幼|星上门|行长王益|形透视镜|型手枪|姓忽悠|幸运码|性爱日|性福情|性感少|性推广歌|胸主席|徐玉元|学骚乱|学位證|學生妹|丫与王益|烟感器|严晓玲|言被劳教|言论罪|盐酸曲|颜射|恙虫病|姚明进去|要人权|要射精了|要射了|要泄了|夜激情|液体炸|一小撮别|遗情书|蚁力神|益关注组|益受贿|阴间来电|陰唇|陰道|陰戶|淫魔舞|淫情女|淫肉|淫騷妹|淫兽|淫兽学|淫水|淫穴|隐形耳|隐形喷剂|应子弹|婴儿命|咏妓|用手枪|幽谷三|游精佑|有奶不一|右转是政|幼齿类|娱乐透视|愚民同|愚民政|与狗性|玉蒲团|育部女官|冤民大|鸳鸯洗|园惨案|园发生砍|园砍杀|园凶杀|园血案|原一九五七|原装弹|袁腾飞|晕倒型|韵徐娘|遭便衣|遭到警|遭警察|遭武警|择油录|曾道人|炸弹教|炸弹遥控|炸广州|炸立交|炸药的制|炸药配|炸药制|张春桥|找枪手|找援交|找政法委副|赵紫阳|针刺案|针刺伤|针刺事|针刺死|侦探设备|真钱斗地|真钱投注真善忍|真实文凭|真实资格|震惊一个民|震其国土|证到付款|证件办|证件集团|证生成器|证书办|证一次性|政府操|政论区|證件|植物冰|殖器护|指纹考勤|指纹膜|指纹套|至国家高|志不愿跟|制服诱|制手枪|制证定金|制作证件|中的班禅|中共黑|中国不强|种公务员|种学历证|众像羔|州惨案|州大批贪|州三箭|宙最高法|昼将近|主席忏|住英国房|助考|助考网|专业办理|专业代|专业代写|专业助|转是政府|赚钱资料|装弹甲|装枪套|装消音|着护士的胸|着涛哥|姿不对死|资格證|资料泄|梓健特药|字牌汽|自己找枪|自慰用|自由圣|自由亚|总会美女|足球玩法|最牛公安|醉钢枪|醉迷药|醉乙醚|尊爵粉|左转是政|作弊器|作各种证|作硝化甘|唑仑|做爱小|做原子弹|做证件";
		$foodlis_tarr = explode(",",$foodlist);
		foreach ($foodlis_tarr as $k => $v) {
			preg_match_all('#('.$arr.')#', $v, $wordsFound);
			if(count($wordsFound[0])>0){exit(json_encode(array('code' => 1, 'status' => 1, 'msg' => $foodlist)));}
		}
	    load()->model('mc');
		$account_api = WeAccount::create();
		$token = $account_api->getAccessToken();
		$url = "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" . $token;
		$postdata = array("content" => $foodlist);
		$res = ihttp_post($url, json_encode($postdata));
		$res = json_decode($res["content"],true);
		if($res['errcode'] != 0){
			exit(json_encode(array('code' => 1, 'status' => 1, 'msg' => $foodlist)));
		}else{
			if($settings['system_type'] == 1){
				$res = pdo_update($this->modulename . "_user_u", array("foodlist" => $foodlist), array("unionid" => $unionid, "system_id" => $settings['system_id']));
				$res = pdo_update($this->modulename . "_user", array("foodlist" => $foodlist), array("openid" => $openid, "uniacid" => $_W["uniacid"]));
			}else{
				$res = pdo_update($this->modulename . "_user", array("foodlist" => $foodlist), array("openid" => $openid, "uniacid" => $_W["uniacid"]));
			}
			exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => $foodlist)));
		}
	case "ad":
		$cateid = intval($_GPC["cateid"]);
		$condition = "uniacid = {$_W['uniacid']} AND cateid = {$cateid} AND is_show = 1";
		$orders = " ORDER BY displayorder DESC";
		$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad")." WHERE ".$condition.$orders);
		
		$resArr['code'] = 0;
		$resArr['status'] = 1;
		$resArr['msg'] = 'SUCCESS';
		$resArr['swiperitems'] = array();
		$i = 0;
		foreach($list as $k=>$v){
			if($v['elmwm_act_id'] == ''){$v['elmwm_act_id'] = 0;}
			if($v['is_ios'] == 1 && $v['elmwm_act_id'] == 0){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 1){
					$resArr['swiperitems'][$i] = array('item_id'=>$v['id'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 1){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 1 && $user['parent_id'] > 0){
					$resArr['swiperitems'][$i] = array('item_id'=>$v['id'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 2){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 1 && $user['parent_id'] == 0){
					$resArr['swiperitems'][$i] = array('item_id'=>$v['id'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}
			if($v['is_ios'] == 2 && $v['elmwm_act_id'] == 0){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 0){
					$resArr['swiperitems'][$i] = array('item_id'=>$v['id'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 1){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 0 && $user['parent_id'] > 0){
					$resArr['swiperitems'][$i] = array('item_id'=>$v['id'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 2){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 0 && $user['parent_id'] == 0){
					$resArr['swiperitems'][$i] = array('item_id'=>$v['id'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}
			if($v['is_ios'] == 0 && $v['elmwm_act_id'] == 0){
				$resArr['swiperitems'][$i] = array('item_id'=>$v['id'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
				$i++;
			}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 1){
				if($user['parent_id'] > 0){
					$resArr['swiperitems'][$i] = array('item_id'=>$v['id'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 2){
				if($user['parent_id'] == 0){
					$resArr['swiperitems'][$i] = array('item_id'=>$v['id'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}
			
			
		}
		$ret = array();
		$ret["data"] = $resArr;
		if($settings['errorcodeid'] == 35){
			var_dump($resArr);
		}
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "movielist":
		$index = intval($_GPC["index"]);
		$keyword = trim($_GPC["keyword"]);
		$cityid = intval($_GPC["cityid"]);
		$lon = $_GPC["lon"];
		$lat = $_GPC["lat"];
		if($index == 1){
			$time = time();
			$data = array("appKey" => $settings['movie_api_s_appKey'], "time" => $time);
			$sign = $this->get_sign($data, $settings['movie_api_s_appSecret']);
			$data["sign"] = $sign;
			$url = $settings['movie_api_s_url'] . "movieapi/movie-info/get-hot-list";
			$res = ihttp_request($url, json_encode($data), array("CURLOPT_HTTPHEADER" => array("Content-Type: application/json;charset=utf-8")));
			if($settings['errorcodeid'] == 36){
				var_dump($res);
			}
			$res = json_decode($res["content"], true);
			if (!empty($keyword)) {
				$res["data"]['list'] = $this->search($res["data"]['list'], $keyword);
			}
			$hot = $res["data"]['list'];
			$c = 0;
			foreach($hot as $k=>$v){
				if(strtotime($v['publishDate'])<time()){
					$hot[$k]['status'] = 1;
				}else{
					$hot[$k]['status'] = 0;
					$indexcome[$c] = $v;
					$indexcome[$c]['status'] = 0;
					$c++;

				}
			}
			$hot = $hot;
			$hotshuliang = count($res["data"]['list']);
			$hotindex = array_slice($hot,0,10);
			$indexcomeshuliang = count($indexcome);
			$indexcome = array_slice($indexcome,0,10);
		}


		if($index == 2){
			//影院列表
			$time = time();
			$data = array("appKey" => $settings['movie_api_s_appKey'], "time" => $time, "cityId" => $cityid);
			$sign = $this->get_sign($data, $settings['movie_api_s_appSecret']);
			$data["sign"] = $sign;
			$url = $settings['movie_api_s_url'] . "movieapi/movie-info/get-cinema-list";
			$res = ihttp_request($url, json_encode($data), array("CURLOPT_HTTPHEADER" => array("Content-Type: application/json;charset=utf-8")));
			if($settings['errorcodeid'] == 36){
				var_dump($res);
			}
			$res = json_decode($res["content"], true);//getDistance
			if (!empty($keyword)) {
				$res["data"]['list'] = $this->cinemasearch($res["data"]['list'], $keyword);
			}
			$cinemalist = $res['data']['list'];
			foreach($cinemalist as $k => $v){
				$distance = $this->getDistance2($lon,$lat,$v['longitude'],$v['latitude']);
				$cinema[] = ['distance' => $distance,'cinemaId' =>$v['cinemaId'],'cityId' =>$v['cityId'],'cinemaName' =>$v['cinemaName'],'address' =>$v['address'],'latitude' =>$v['latitude'],'longitude' =>$v['longitude'],'phone' =>$v['phone'],'regionName' =>$v['regionName']];
			}
			$get_colum = array_column($cinema,'distance');
			array_multisort($get_colum,SORT_ASC,$cinema);

		}
		if($index == 3){
			$time = time();
			$data = array("appKey" => $settings['movie_api_s_appKey'], "time" => $time);
			$sign = $this->get_sign($data, $settings['movie_api_s_appSecret']);
			$data["sign"] = $sign;
			$url = $settings['movie_api_s_url'] . "movieapi/movie-info/get-soon-list";
			$res = ihttp_request($url, json_encode($data), array("CURLOPT_HTTPHEADER" => array("Content-Type: application/json;charset=utf-8")));
			if($settings['errorcodeid'] == 36){
				var_dump($res);
			}
			$res = json_decode($res["content"], true);
			if (!empty($keyword)) {
				$res["data"]['list'] = $this->search($res["data"]['list'], $keyword);
			}
			$come = $res["data"]['list'];
			foreach($come as $k=>$v){
				if(strtotime($v['publishDate'])<time()){
					$come[$k]['status'] = 1;
				}else{
					$come[$k]['status'] = 0;
				}
			}
			$come = array_slice($come,0,50);
			$comeshuliang = count($res["data"]['list']);

		}
		
		$resArr['movie'] = array("hotshuliang" => $hotshuliang, "hot" => $hot, "hotindex" => $hotindex,"comeshuliang" => $comeshuliang, "come" => $come, "cinema" => $cinema,'indexcome' => $indexcome,'indexcomeshuliang' => $indexcomeshuliang);
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "moviedetail":
		$movie_id = intval($_GPC["id"]);
		$cityid = intval($_GPC["cityid"]);
		$time = time();
		$data = array("appKey" => $settings['movie_api_s_appKey'], "time" => $time, "filmId" => $movie_id, "cityId" => $cityid);
		$sign = $this->get_sign($data, $settings['movie_api_s_appSecret']);
		$data["sign"] = $sign;
		$url = $settings['movie_api_s_url'] . "movieapi/movie-info/get-show-date";
		$res = ihttp_request($url, json_encode($data), array("CURLOPT_HTTPHEADER" => array("Content-Type: application/json;charset=utf-8")));
		if($settings['errorcodeid'] == 36){
			var_dump($res);
		}
		$res = json_decode($res["content"], true);
		$day = $res["data"]['dateList'];
		foreach($day as $k => $v){
			$resArr['day'][] = $this->zhouji($v).$v;
		}
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "cinemaList":
		$movie_id = intval($_GPC["id"]);
		$cityid = intval($_GPC["cityid"]);
		$date = preg_replace('/([\x80-\xff]*)/i','',$_GPC["date"]);
		$pageIndex = intval($_GPC["pageIndex"]);
		$pageSize = 40;
		$lon = $_GPC["lon"];
		$lat = $_GPC["lat"];
		$time = time();
		$data = array("appKey" => $settings['movie_api_s_appKey'], "time" => $time, "filmId" => $movie_id, "cityId" => $cityid, "page" => 1, "limit" => 40, "date" => $date, "latitude" => $lat, "longitude" => $lon);
		$sign = $this->get_sign($data, $settings['movie_api_s_appSecret']);
		$data["sign"] = $sign;
		$url = $settings['movie_api_s_url'] . "movieapi/movie-info/get-show-list";
		$res = ihttp_request($url, json_encode($data), array("CURLOPT_HTTPHEADER" => array("Content-Type: application/json;charset=utf-8")));
		if($settings['errorcodeid'] == 36){
			var_dump($res);
		}
		$res = json_decode($res["content"], true);
		if($res['success']){
			$resArr['cinemaList'] = $res['data']['list'];
		}
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "cinemaMovieList":
		$movieId = intval($_GPC["id"]);
		$moviedate = preg_replace('/([\x80-\xff]*)/i','',$_GPC["moviedate"]);
		$cinemaId = intval($_GPC["cinemaId"]);
		$type = intval($_GPC["type"]);
		$hotmovie = str_replace("&quot;",'"',$_GPC["hotmovie"]);
		$hotmovie = json_decode($hotmovie,true);
		$time = time();
		$data = array("appKey" => $settings['movie_api_s_appKey'], "time" => $time, "cinemaId" => $cinemaId);
		$sign = $this->get_sign($data, $settings['movie_api_s_appSecret']);
		$data["sign"] = $sign;
		$url = $settings['movie_api_s_url'] . "movieapi/movie-info/get-schedule-list";
		$res = ihttp_request($url, json_encode($data), array("CURLOPT_HTTPHEADER" => array("Content-Type: application/json;charset=utf-8")));
		if($settings['errorcodeid'] == 36){
			var_dump($res);
		}
		if($settings['system_type'] == 1){
			pdo_update($this->modulename . "_user_u", array('movieshow' => $res["content"]), array("unionid" => $unionid, "system_id" => $settings['system_id']));
		}else{
			pdo_update($this->modulename . "_user", array('movieshow' => $res["content"]), array("openid" => $openid, "uniacid" => $_W["uniacid"]));
		}
		$res = json_decode($res["content"], true);
		$cinemaMovieList = $res['data']['list'];
		
		if($type == 1){
			$tmp_arr = array();
			foreach($cinemaMovieList as $k => $v){  
				if(in_array($v['filmId'], $tmp_arr)){  
					//unset($cinemaMovieList[$k]);
				}else{
					$cinemaMovieList_list[] = $v;
					$tmp_arr[$k] = $v['filmId'];
				}
			}
			$i = 0;
			foreach($cinemaMovieList_list as $k=>$v){
				foreach($hotmovie as $kk=>$vv){
					if($vv['filmId'] == $v['filmId']){
						$resArr['movieList'][] = $vv;
						$i++;
						break;
					}
				}
			}
		}
		if($type == 2){
			$ii = 0;$iii = 0;
			foreach($cinemaMovieList as $k=>$v){
				if($v['filmId'] == $movieId){
					if($moviedate && $v['showDate'] == $moviedate){
						if($settings['movie_price1'] > 0 && $settings['movie_netprice'] > 0){
							if($v['netPrice']<=$settings['movie_netprice']*100){
								$v['price'] = round($v['netPrice']*$settings['movie_price']/10000,2);
							}else{
								$v['price'] = round($v['netPrice']*$settings['movie_price1']/10000,2);
							}
						}else{
							$v['price'] = round($v['netPrice']*$settings['movie_price']/10000,2);
						}
						$v['netPrice'] = round($v['netPrice']/100,2);
						$v['start_time'] = date("H:i",strtotime($v['showTime']));
						$v['end_time'] = date("H:i",strtotime($v['showTime']. " +".$v['duration']." minutes"));
						if(strtotime($v['showTime'])-3720 <= time()){
							$v['stop'] = 1;
						}else{
							$v['stop'] = 2;
						}
						$resArr['movieaction'][] = $v;
						$ii++;
					}
					$showDate = $this->zhouji($v['showDate']).$v['showDate'];
					if(!in_array($showDate,$resArr['moviedate'])){
						$resArr['moviedate'][$iii] = $showDate;
						$resArr['moviedate2'][$iii] = $v['showDate'];
						if($v['showDate'] == $moviedate){
							$resArr['cdate'] = $iii;
						}
						$iii++;
					}
				}
			}
			
			if(empty($resArr['movieaction'])){
				foreach($cinemaMovieList as $k=>$v){
					if($v['filmId'] == $movieId){
						if($v['showDate'] == $resArr['moviedate2'][0]){
							if($settings['movie_price1'] > 0 && $settings['movie_netprice'] > 0){
								if($v['netPrice']<=$settings['movie_netprice']*100){
									$v['price'] = round($v['netPrice']*$settings['movie_price']/10000,2);
								}else{
									$v['price'] = round($v['netPrice']*$settings['movie_price1']/10000,2);
								}
							}else{
								$v['price'] = round($v['netPrice']*$settings['movie_price']/10000,2);
							}
							$v['netPrice'] = round($v['netPrice']/100,2);
							$v['start_time'] = date("H:i",strtotime($v['showTime']));
							$v['end_time'] = date("H:i",strtotime($v['showTime']. " +".$v['duration']." minutes"));
							if(strtotime($v['showTime'])-3720 <= time()){
								$v['stop'] = 1;
							}else{
								$v['stop'] = 2;
							}
							$resArr['movieaction'][] = $v;
						}
					}
				}
			}
			if(!$resArr['cdate']){$resArr['cdate'] = 0;}
			//$resArr['moviedate'] = array_unique($resArr['moviedate']);
		}
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case 'seatbuy':
		if(strtotime($_GPC["order_showTime"])-3620 <= time()){
			exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '已停售，请提前1小时购票')));
		}
		
		if(!$_GPC["order_reservedPhone"] || !$_GPC["order_acceptChangeSeat"] || !$_GPC["order_filmId"] || !$_GPC["order_showId"] || !$_GPC["order_filmName"] || !$_GPC["order_filmPic"] || !$_GPC["order_time"] || !$_GPC["order_cinemaName"] || !$_GPC["order_cinemaId"] || !$_GPC["order_hallName"] || !$_GPC["order_seat"] || !$_GPC["order_showTime"] || !$_GPC["order_stopSellTime"] || !$_GPC["order_ticketNum"] || !$_GPC["order_selectedOriginPrice"] || !$_GPC["order_selectedRealPrice"]){
			exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '参数不完整')));
		}
		if($_GPC["order_acceptChangeSeat"] == 2){$_GPC["order_acceptChangeSeat"] = 0;}
		$order['reservedPhone'] = $_GPC["order_reservedPhone"];
		$order['acceptChangeSeat'] = $_GPC["order_acceptChangeSeat"];
		$order['filmId'] = $_GPC["order_filmId"];
		$order['showId'] = $_GPC["order_showId"];
		$order['filmName'] = $_GPC["order_filmName"];
		$order['filmPic'] = $_GPC["order_filmPic"];
		$order['time'] = $_GPC["order_time"];
		$order['cinemaName'] = $_GPC["order_cinemaName"];
		$order['cinemaId'] = $_GPC["order_cinemaId"];
		$order['hallName'] = $_GPC["order_hallName"];
		$order['seat'] = $_GPC["order_seat"];
		$order['showTime'] = $_GPC["order_showTime"];
		$order['stopSellTime'] = $_GPC["order_stopSellTime"];
		$order['duration'] = $_GPC["order_duration"];
		$order['movieTheaterName'] = $_GPC["order_movieTheaterName"];
		$order['ticketNum'] = $_GPC["order_ticketNum"];
		$order['selectedOriginPrice'] = $_GPC["order_selectedOriginPrice"];
		$order['selectedRealPrice'] = $_GPC["order_selectedRealPrice"];
		if($settings['system_type'] == 1){
			$muser = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings["system_id"]));
		}else{
			$muser = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
		}
		$movieshow = json_decode($muser["movieshow"], true);
		$movieshow = $movieshow['data']['list'];
		$user_order_id = $muser['user_id'].date("YmdHis");
		
		foreach($movieshow as $k=>$v){
			if($order['showId'] == $v['showId']){
				$o = $v;
				break;
			}
		}
		if(!$o){
			exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '订单信息错误')));
		}
		$initPrice = round($o['netPrice'] * $order['ticketNum'],2);
		if($settings['movie_price1'] > 0 && $settings['movie_netprice'] > 0){
			if($o['netPrice']<=$settings['movie_netprice']*100){
				$orderPrice = round($o['netPrice'] * $settings["movie_price"] * $order['ticketNum']/100,0);
			}else{
				$orderPrice = round($o['netPrice'] * $settings["movie_price1"] * $order['ticketNum']/100,0);
			}
		}else{
			$orderPrice = round($o['netPrice'] * $settings["movie_price"] * $order['ticketNum']/100,0);
		}
		$insert = array("uniacid" => $_W["uniacid"], "system_id" => $settings["system_id"], "user_id" => $muser['user_id'], "openid" => $openid, "unionid" => $muser['unionid'], "api_appKey" => $settings['movie_api_s_appKey'], "userOrderId" => $user_order_id, "thirdOrderId" => $settings['movie_api_s_appKey'].'_'.$order['cinemaId'].'_'.$user_order_id, "orderStatus" => 2,'orderStatusStr' => '受理中', "initPrice" => $initPrice, "orderPrice" => $orderPrice, "filmId" => $order['filmId'], "filmName" => $order['filmName'], "filmPic" => $order['filmPic'], "cinemaId" => $order['cinemaId'], "cinemaName" => $order['cinemaName'], "hallName" => $order['hallName'], "showTime" => $order['showTime'], "stopSellTime" => $order['stopSellTime'], "showId" => $order['showId'], "seat" => $order['seat'], "orderNum" => $order['ticketNum'], "reservedPhone" => $order['reservedPhone'], "acceptChangeSeat" => $order['acceptChangeSeat'], "createTime" => time());
		pdo_insert($this->modulename . "_movieorder", $insert);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => array('order_id' => $user_order_id))));
	case "seat":
		$showid = trim($_GPC["showid"]);
		$time = time();
		$data = array("appKey" => $settings['movie_api_s_appKey'], "time" => $time, "showId" => $showid);
		$sign = $this->get_sign($data, $settings['movie_api_s_appSecret']);
		$data["sign"] = $sign;
		$url = $settings['movie_api_s_url'] . "movieapi/movie-info/get-seat";
		$res = ihttp_request($url, json_encode($data), array("CURLOPT_HTTPHEADER" => array("Content-Type: application/json;charset=utf-8")));
		if($settings['errorcodeid'] == 36){
			var_dump($res);
		}
		$res = json_decode($res["content"], true);
		$resArr['seatData'] = $res['data']['seatData'];
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "moviecity":
		$time = time();
		$data = array("appKey" => $settings['movie_api_s_appKey'], "time" => $time);
		$sign = $this->get_sign($data, $settings['movie_api_s_appSecret']);
		$data["sign"] = $sign;
		$url = $settings['movie_api_s_url'] . "movieapi/movie-info/get-city-list";
		$res = ihttp_request($url, json_encode($data), array("CURLOPT_HTTPHEADER" => array("Content-Type: application/json;charset=utf-8")));
		if($settings['errorcodeid'] == 36){
			var_dump($res);
		}
		$res = json_decode($res["content"], true);
		$resArr['ocityData'] = $res['data']['list'];
		$resArr['cityData'] = $res['data']['list'];
		$ch = 65;
		for ($i=0;$i<26;$i++){
			foreach ($resArr['cityData'] as $key => $val) {
				if(chr($ch+$i) == $val['pinYin']){
					$cityData[chr($ch+$i)][] = $val;
				}
			}
		}
		$resArr['cityData'] = $cityData;
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "movieday":
		$cityid = intval($_GPC["cityid"]);
		$movieId = intval($_GPC["id"]);
		$cinemaId = intval($_GPC["cinemaId"]);
		$url = "https://live.qianzhu8.com/api/movie/day";
		$data = array("cityId" => $cityid,"movieId" => $movieId,"cinemaId" => $cinemaId);
		$res = ihttp_request($url, json_encode($data), array("CURLOPT_HTTPHEADER" => array("Content-Type: application/json;charset=utf-8")));
		if($settings['errorcodeid'] == 43){
			var_dump($res);
		}
		$res = json_decode($res["content"], true);
		if($res['success']){
			foreach ($res['data'] as $key => $val) {
				$resArr['day'][$key] = $val['month'].'月'.$val['day'].'日（'.$val['week'].'）';
				$resArr['day_detail'][$key] = $val;
			}
		}
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "shows":
		$date = intval($_GPC["date"]);
		$pageIndex = intval($_GPC["pageIndex"]);
		$pageSize = 40;
		$cityid = intval($_GPC["cityid"]);
		$movieId = intval($_GPC["id"]);
		$cinemaId = intval($_GPC["cinemaId"]);
		$url = "https://live.qianzhu8.com/api/movie/shows";
		$data = array("date" => $date,"cinemaId" => $cinemaId,"movieId" => $movieId,"pageIndex" => $pageIndex,"pageSize" => $pageSize);
		$res = ihttp_request($url, json_encode($data), array("CURLOPT_HTTPHEADER" => array("Content-Type: application/json;charset=utf-8")));
		if($settings['errorcodeid'] == 44){
			var_dump($res);
		}
		$res = json_decode($res["content"], true);
		if($res['success']){
			$resArr['shows'] = $res['data'];
		}
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "moviebuyurl":
		$date = intval($_GPC["date"]);
		$pageIndex = intval($_GPC["pageIndex"]);
		$pageSize = 40;
		$cityid = intval($_GPC["cityid"]);
		$movieId = intval($_GPC["id"]);
		$cinemaId = intval($_GPC["cinemaId"]);
		$url = "https://live.qianzhu8.com/api/movie/shows";
		$data = array("date" => $date,"cinemaId" => $cinemaId,"movieId" => $movieId,"pageIndex" => $pageIndex,"pageSize" => $pageSize);
		$res = ihttp_request($url, json_encode($data), array("CURLOPT_HTTPHEADER" => array("Content-Type: application/json;charset=utf-8")));
		if($settings['errorcodeid'] == 45){
			var_dump($res);
		}
		$res = json_decode($res["content"], true);
		if($res['success']){
			$resArr['shows'] = $res['data'];
		}
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "movieaddress":
		$lat = trim($_GPC["lat"]);
		$lon = trim($_GPC["lon"]);
		$url = "https://live.qianzhu8.com/api/city/location";
		$timestamp = time();
		$data = array("lat" => $lat, "lon" => $lon);
		$res = ihttp_request($url, json_encode($data), array("CURLOPT_HTTPHEADER" => array("Content-Type: application/json;charset=utf-8")));
		if($settings['errorcodeid'] == 46){
			var_dump($res);
		}
		$res = json_decode($res["content"], true);
		$resArr['city'] = $res['data']['name'];
		$resArr['cityid'] = $res['data']['id'];
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "goods":
		$pagesize = intval($_GPC["pagesize"]);
		if($pagesize > 0){
			$psize = $pagesize;
		}else{
			if($settings['index_creditnum'] === NULL){$settings['index_creditnum'] = 4;}else{$settings['index_creditnum'] = $settings['index_creditnum'] * 1;}
			$psize = $settings['index_creditnum'];
		}
		$pindex = max(1, intval($_GPC["page"]));
		$condition = " WHERE `uniacid` = '{$_W['uniacid']}' AND is_del = 0 AND is_sale = 1 ";
		$orderby = " ORDER BY sort DESC ";
		$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_item") . $condition . $orderby . " LIMIT " . ($pindex - 1) * $psize . "," . $psize);
		$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_item") . $condition);
		$items = array();
		foreach ($list as $key => $val) {
			$photos = array();
			if (!empty($val["photos"])) {
				$photos = json_decode($val["photos"], true);
				foreach ($photos as $k => $v) {
					$photos[$k] = $_W["attachurl"] . $v;
				}
			}
			$items['items'][] = array("item_id" => $val["item_id"], "title" => $val["title"], "desc" => $val["desc"], "price" => $val["price"], "mprice" => $val["market_price"], "sold" => $val["sold"], "photos" => $photos);
		}
		$ret = array();
		$ret["data"] = $items;
		if($settings['errorcodeid'] == 47){
			var_dump($items);
		}
		$ret["total"] = ceil($total / $psize);
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "pagelist":
		$psize = 8;
		$pindex = max(1, intval($_GPC["page"]));
		$condition = " WHERE `uniacid` = '{$_W['uniacid']}' AND is_show = 1 ";
		$orderby = " ORDER BY displayorder DESC ";
		$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_page") . $condition . $orderby . " LIMIT " . ($pindex - 1) * $psize . "," . $psize);
		$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_page") . $condition);
		$items = array();
		foreach ($list as $key => $val) {
			$items['items'][] = array("page_id" => $val["page_id"], "title" => $val["title"], "desc" => $val["desc"], "name" => $val["name"], "post_time" => date('Y-m-d H:i',$val["post_time"]), "thumb" => $_W["attachurl"] . $val["thumb"], "avatar" => $_W["attachurl"] . $val["avatar"], "content" => $this->html2Array(html_entity_decode($val["content"])));
		}
		$ret = array();
		$ret["data"] = $items;
		if($settings['errorcodeid'] == 48){
			var_dump($items);
		}
		$ret["total"] = ceil($total / $psize);
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "tasklist":
		$psize = 10;
		$pindex = max(1, intval($_GPC["page"]));
		if($settings['system_type'] == 1){
			$openid2 = 'unionid';
			$openid1 = $unionid;
			$uniacid = 'system_id';
			$uniacid1 = $settings['system_id'];
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
		}else{
			$openid2 = 'user_id';
			$openid1 = $user['user_id'];
			$uniacid = 'uniacid';
			$uniacid1 = $_W["uniacid"];
		}

		$condition = " WHERE {$uniacid} = {$uniacid1} AND is_online = 1 AND status = 1 AND (user_type = {$user['is_tuan']} OR user_type = 99) AND start_time <=".time()." AND end_time >= ".time();
		$orderby = " ORDER BY displayorder DESC ";
		$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_task") . $condition . $orderby . " LIMIT " . ($pindex - 1) * $psize . "," . $psize);
		$items = array();
		foreach ($list as $key => $val) {
			if($val['task_type'] == 0){
				if($val['is_retask'] <= 1){
					$user_task_list = pdo_fetchall("SELECT count(*) as num FROM " . tablename($this->modulename."_user_task") . " WHERE ".$openid2." = '{$openid1}' and task_id = ".$val['task_id']." AND status = 1 AND ".$uniacid." = ".$uniacid1);
					if($val['is_retask'] == 0){$val['re_num'] = 1;}
					if($user_task_list[0]['num'] >= $val['re_num']){
						continue;
					}
				}
				$allnum = round($val['invite_sum'] * 1 + $val['invite_allsum'] * 1 + $val['invite_yxsum'] * 1 + $val['invite_yxallsum'] * 1 + $val['invite_tuan'] * 1 + $val['invite_alltuan'] * 1 + $val['invite_he'] * 1 + $val['invite_allhe'] * 1 + $val['order_sum'] * 1 + $val['invite_order'] * 1 + $val['invite_allorder'] * 1 + $val['money'] * 1 + $val['invite_money'] * 1 + $val['invite_allmoney'] * 1 + $val['allmoney'] * 1,0);
				if($settings['system_type'] == 1){
					$userall = pdo_get($this->modulename . "_user_task", array("unionid" => $user['unionid'] ,"task_id" => $val['task_id'] , "status" => 0 ,"system_id" => $settings['system_id']));
				}else{
					$userall = pdo_get($this->modulename . "_user_task", array("user_id" => $user['user_id'] ,"task_id" => $val['task_id'] , "status" => 0 ,"uniacid" => $_W["uniacid"]));
				}

				if($userall['invite_sum'] >= $val['invite_sum']){$userall['invite_sum'] = $val['invite_sum'];}
				if($userall['invite_allsum'] >= $val['invite_allsum']){$userall['invite_allsum'] = $val['invite_allsum'];}
				if($userall['invite_yxsum'] >= $val['invite_yxsum']){$userall['invite_yxsum'] = $val['invite_yxsum'];}
				if($userall['invite_yxallsum'] >= $val['invite_yxallsum']){$userall['invite_yxallsum'] = $val['invite_yxallsum'];}
				if($userall['invite_tuan'] >= $val['invite_tuan']){$userall['invite_tuan'] = $val['invite_tuan'];}
				if($userall['invite_alltuan'] >= $val['invite_alltuan']){$userall['invite_alltuan'] = $val['invite_alltuan'];}
				if($userall['invite_he'] >= $val['invite_he']){$userall['invite_he'] = $val['invite_he'];}
				if($userall['invite_allhe'] >= $val['invite_allhe']){$userall['invite_allhe'] = $val['invite_allhe'];}
				if($userall['order_sum'] >= $val['order_sum']){$userall['order_sum'] = $val['order_sum'];}
				if($userall['invite_order'] >= $val['invite_order']){$userall['invite_order'] = $val['invite_order'];}
				if($userall['invite_allorder'] >= $val['invite_allorder']){$userall['invite_allorder'] = $val['invite_allorder'];}
				if($userall['money'] >= $val['money']){$userall['money'] = $val['money'];}
				if($userall['invite_money'] >= $val['invite_money']){$userall['invite_money'] = $val['invite_money'];}
				if($userall['invite_allmoney'] >= $val['invite_allmoney']){$userall['invite_allmoney'] = $val['invite_allmoney'];}
				if($userall['allmoney'] >= $val['allmoney']){$userall['allmoney'] = $val['allmoney'];}

				$userallnum = round($userall['invite_sum'] * 1 + $userall['invite_allsum'] * 1 + $userall['invite_yxsum'] * 1 + $userall['invite_yxallsum'] * 1 + $userall['invite_tuan'] * 1 + $userall['invite_alltuan'] * 1 + $userall['invite_he'] * 1 + $userall['invite_allhe'] * 1 + $userall['order_sum'] * 1 + $userall['invite_order'] * 1 + $userall['invite_allorder'] * 1 + $userall['money'] * 1 + $userall['invite_money'] * 1 + $userall['invite_allmoney'] * 1 + $userall['allmoney'] * 1,0);



				
				if($allnum == 1){
					$bili = '进行中';
					$width = 320;
				}else{
					if($userallnum >= $allnum){
						$bili = $allnum.'/'.$allnum;
						$width = 540;
					}else{
						$bili = $userallnum.'/'.$allnum;
						$width = round($userallnum/$allnum * 540,0);
					}
				}
			}else{
				$bili = '进行中';
				$width = 320;
			}
			
			$items['tasklist'][] = array("task_id" => $val["task_id"], "name" => $val["name"], "invite_sum" => $val["invite_sum"], "invite_allsum" => $val["invite_allsum"], "invite_yxsum" => $val["invite_yxsum"], "invite_yxallsum" => $val["invite_yxallsum"], "invite_tuan" => $val["invite_tuan"], "invite_alltuan" => $val["invite_alltuan"], "invite_he" => $val["invite_he"], "invite_allhe" => $val["invite_allhe"], "order_sum" => $val["order_sum"], "invite_order" => $val["invite_order"], "invite_allorder" => $val["invite_allorder"], "money" => $val["money"], "invite_money" => $val["invite_money"], "invite_allmoney" => $val["invite_allmoney"], "allmoney" => $val["allmoney"], "up_type" => $val["up_type"], "up_money" => $val["up_money"], "up_credit" => $val["up_credit"], "is_retask" => $val["is_retask"], "re_num" => $val["re_num"],"desc" => $val["desc"],"is_lq" => $val["is_lq"],"item_id" => $val["item_id"],"page_id" => $val["page_id"],"url" => $val["url"],"bglineColor" => $val["bglineColor"],"bglineAColor" => $val["bglineAColor"],"barBgColor_left" => $val["barBgColor_left"],"barBgColor_right" => $val["barBgColor_right"],"BgColor_wl" => $val["BgColor_wl"],"BgColor_yl" => $val["BgColor_yl"],"desc_color" => $val["desc_color"],"allnum" => $allnum,"userallnum" => $userallnum,"bili" => $bili,"width" => $width,"jp_url" => tomedia($val["jp_url"]),"lq_url" => tomedia($val["lq_url"]));
		}
		$ret = array();
		$ret["data"] = $items;
		if($settings['errorcodeid'] == 148){
			var_dump($items);
		}
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "donetasklist":
		$psize = 10;
		$pindex = max(1, intval($_GPC["page"]));
		if($settings['system_type'] == 1){
			$uniacid = 'system_id';
			$uniacid1 = $settings['system_id'];
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
		}else{
			$uniacid = 'uniacid';
			$uniacid1 = $_W["uniacid"];
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
		}

		$condition = " WHERE `{$uniacid}` = '{$uniacid1}' AND is_online = 1 AND status = 1 AND user_type = {$user['is_tuan']} AND start_time <=".time()." AND end_time >= ".time();
		$orderby = " ORDER BY displayorder DESC ";
		$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_task") . $condition . $orderby . " LIMIT " . ($pindex - 1) * $psize . "," . $psize);
		$items = array();
		foreach ($list as $key => $val) {
			$allnum = round($val['invite_sum'] * 1 + $val['invite_allsum'] * 1 + $val['invite_yxsum'] * 1 + $val['invite_yxallsum'] * 1 + $val['invite_tuan'] * 1 + $val['invite_alltuan'] * 1 + $val['invite_he'] * 1 + $val['invite_allhe'] * 1 + $val['order_sum'] * 1 + $val['invite_order'] * 1 + $val['invite_allorder'] * 1 + $val['money'] * 1 + $val['invite_money'] * 1 + $val['invite_allmoney'] * 1 + $val['allmoney'] * 1,0);
			if($settings['system_type'] == 1){
				$userall = pdo_get($this->modulename . "_user_task", array("unionid" => $user['unionid'] ,"task_id" => $val['task_id'] , "status" => 0 ,"system_id" => $settings['system_id']));
			}else{
				$userall = pdo_get($this->modulename . "_user_task", array("user_id" => $user['user_id'] ,"task_id" => $val['task_id'] , "status" => 0 ,"uniacid" => $_W["uniacid"]));
			}

			$userallnum = round($userall['invite_sum'] * 1 + $userall['invite_allsum'] * 1 + $userall['invite_yxsum'] * 1 + $userall['invite_yxallsum'] * 1 + $userall['invite_tuan'] * 1 + $userall['invite_alltuan'] * 1 + $userall['invite_he'] * 1 + $userall['invite_allhe'] * 1 + $userall['order_sum'] * 1 + $userall['invite_order'] * 1 + $userall['invite_allorder'] * 1 + $userall['money'] * 1 + $userall['invite_money'] * 1 + $userall['invite_allmoney'] * 1 + $userall['allmoney'] * 1,0);

			if($userallnum >= $allnum){
				$bili = $allnum.'/'.$allnum;
				$width = 540;
			}else{
				$bili = $userallnum.'/'.$allnum;
				$width = round($userallnum/$allnum * 540,0);
			}
			$items['donetasklist'][] = array("task_id" => $val["task_id"], "name" => $val["name"], "invite_sum" => $val["invite_sum"], "invite_allsum" => $val["invite_allsum"], "invite_yxsum" => $val["invite_yxsum"], "invite_yxallsum" => $val["invite_yxallsum"], "invite_tuan" => $val["invite_tuan"], "invite_alltuan" => $val["invite_alltuan"], "invite_he" => $val["invite_he"], "invite_allhe" => $val["invite_allhe"], "order_sum" => $val["order_sum"], "invite_order" => $val["invite_order"], "invite_allorder" => $val["invite_allorder"], "money" => $val["money"], "invite_money" => $val["invite_money"], "invite_allmoney" => $val["invite_allmoney"], "allmoney" => $val["allmoney"], "up_type" => $val["up_type"], "up_money" => $val["up_money"], "up_credit" => $val["up_credit"], "is_retask" => $val["is_retask"], "re_num" => $val["re_num"],"desc" => $val["desc"],"is_lq" => $val["is_lq"],"item_id" => $val["item_id"],"page_id" => $val["page_id"],"url" => $val["url"],"bglineColor" => $val["bglineColor"],"bglineAColor" => $val["bglineAColor"],"barBgColor_left" => $val["barBgColor_left"],"barBgColor_right" => $val["barBgColor_right"],"BgColor_wl" => $val["BgColor_wl"],"BgColor_yl" => $val["BgColor_yl"],"desc_color" => $val["desc_color"],"allnum" => $allnum,"userallnum" => $userallnum,"bili" => $bili,"width" => $width,"jp_url" => tomedia($val["jp_url"]),"lq_url" => tomedia($val["lq_url"]));
		}
		$items['donetasklist']=array();
		$ret = array();
		$ret["data"] = $items;
		if($settings['errorcodeid'] == 148){
			var_dump($items);
		}
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "tasklq":
		$taskid = intval($_GPC["taskid"]);
		if($settings['system_type'] == 1){
			$val = pdo_get($this->modulename . "_task", array("task_id" => $taskid, "system_id" => $settings['system_id']));
			$userall = pdo_get($this->modulename . "_user_task", array("task_id" => $taskid,"unionid" => $unionid, "system_id" => $settings['system_id']));
		}else{
			$val = pdo_get($this->modulename . "_task", array("task_id" => $taskid, "uniacid" => $_W["uniacid"]));
			$userall = pdo_get($this->modulename . "_user_task", array("task_id" => $taskid,"user_id" => $user['user_id'], "uniacid" => $_W["uniacid"]));
		}

		$allnum = round($val['invite_sum'] * 1 + $val['invite_allsum'] * 1 + $val['invite_yxsum'] * 1 + $val['invite_yxallsum'] * 1 + $val['invite_tuan'] * 1 + $val['invite_alltuan'] * 1 + $val['invite_he'] * 1 + $val['invite_allhe'] * 1 + $val['order_sum'] * 1 + $val['invite_order'] * 1 + $val['invite_allorder'] * 1 + $val['money'] * 1 + $val['invite_money'] * 1 + $val['invite_allmoney'] * 1 + $val['allmoney'] * 1,0);

		$userallnum = round($userall['invite_sum'] * 1 + $userall['invite_allsum'] * 1 + $userall['invite_yxsum'] * 1 + $userall['invite_yxallsum'] * 1 + $userall['invite_tuan'] * 1 + $userall['invite_alltuan'] * 1 + $userall['invite_he'] * 1 + $userall['invite_allhe'] * 1 + $userall['order_sum'] * 1 + $userall['invite_order'] * 1 + $userall['invite_allorder'] * 1 + $userall['money'] * 1 + $userall['invite_money'] * 1 + $userall['invite_allmoney'] * 1 + $userall['allmoney'] * 1,0);

		if($userallnum >= $allnum){
			if($settings['system_type'] == 1){
				$uniacid = 'system_id';
				$uniacid1 = $settings['system_id'];
				$tb_last = '_u';
				$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
			}else{
				$uniacid = 'uniacid';
				$uniacid1 = $_W["uniacid"];
				$tb_last = '_u';
				$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
			}
		}
		$ret["data"] = $items;
		if($settings['errorcodeid'] == 148){
			var_dump($items);
		}
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "getsignin":
		$is_integral = $settings['is_integral'];
		if ($is_integral == 0 || $is_integral == NULL) {
			exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '签到活动未启用')));
		}
		if (isset($_GPC["goold"])) {
			if($settings['system_type'] == 1){
				$uniacid = 'system_id';
				$uniacid1 = $settings['system_id'];
				$UserInfo = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
			}else{
				$uniacid = 'uniacid';
				$uniacid1 = $_W["uniacid"];
				$UserInfo = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
			}
			$sign_count = $UserInfo["sign_in_continuity"];
			if ($sign_count < 7) {
				$yesterday = date("Y-m-d", strtotime("-1 day"));
				if (!empty($UserInfo["sign_in"])) {
					$last_time = date("Y-m-d", $UserInfo["sign_in"]);
					if ($last_time == date("Y-m-d")) {
						exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '已经签过到了!')));
					} elseif ($last_time == $yesterday) {
						$sign_count += 1;
						$sum = $UserInfo["sign_in_sum"] + 1;
					} else {
						$sign_count = 1;
						$sum = 1;
					}
				} else {
					$sum = $UserInfo["sign_in_sum"] + 1;
					$sign_count += 1;
				}
			} else {
				$sign_count = 1;
				$sum = $UserInfo["sign_in_sum"] + 1;
			}
			$UserInfoData = array("sign_in_continuity" => $sign_count, "sign_in_sum" => $sum, "credit +=" => $settings['signin_'.$sign_count] * 1, "sign_in" => time());
			if($settings['system_type'] == 1){
				pdo_update($this->modulename . "_user_u", $UserInfoData, array("unionid" => $unionid, "system_id" => $settings['system_id']));
			}else{
				pdo_update($this->modulename . "_user", $UserInfoData, array("openid" => $openid, "uniacid" => $_W["uniacid"]));
			}
			if ($UserInfoData) {
				$result = pdo_insert($this->modulename . "_user_creditlogs", array("user_id" => $UserInfo['user_id'],"openid" => $UserInfo['openid'],"unionid" => $UserInfo['unionid'],"uniacid" => $_W["uniacid"], "system_id" => $settings['system_id'], "num" => $_GPC["goold"], "last_num" => $UserInfo['credit'], "create_time" => $_W["timestamp"], "reason" => '签到'));
				if ($result) {
					exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '签到成功')));
				} else {
					exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '签到失败')));
				}
			}
		} else {
			$gold = array("signin_one_day" => $settings['signin_1'] ? $settings['signin_1'] : 10, "signin_two_day" => $settings['signin_2'] ? $settings['signin_2'] : 10, "signin_three_day" => $settings['signin_3'] ? $settings['signin_3'] : 10, "signin_four_day" => $settings['signin_4'] ? $settings['signin_4'] : 10, "signin_five_day" => $settings['signin_5'] ? $settings['signin_5'] : 10, "signin_six_day" => $settings['signin_6'] ? $settings['signin_6'] : 10, "signin_seven_day" => $settings['signin_7'] ? $settings['signin_7'] : 10);
			exit(json_encode(array('code' => 0, 'status' => 1, 'data' => $gold)));
		}
	case "adDoublecredit":
		$is_integral = $settings['is_integral'];
		if ($is_integral == 0 || $is_integral == NULL) {
			exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '签到活动未启用')));
		}
		if($settings['system_type'] == 1){
			$UserInfo = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
			$RecordId = pdo_get($this->modulename . "_task_temp", array("unionid" => $UserInfo['unionid'], "type" => 3, "system_id" => $settings['system_id']), array("id", "addtime"));
		}else{
			$UserInfo = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
			$RecordId = pdo_get($this->modulename . "_task_temp", array("openid" => $UserInfo['openid'], "type" => 3, "uniacid" => $_W["uniacid"]), array("id", "addtime"));
		}
		
		$last_time = date("Y-m-d", $RecordId["addtime"]);
		if ($last_time == date("Y-m-d")) {
			exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '已经领取过了!')));
		}
		$day = $UserInfo['sign_in_continuity'] * 1;
		if($settings['system_type'] == 1){
			$result = pdo_update($this->modulename . "_user_u", array('credit +=' => $settings['signin_'.$day] * 1), array("unionid" => $unionid, "system_id" => $settings['system_id']));
		}else{
			$result = pdo_update($this->modulename . "_user", array('credit +=' => $settings['signin_'.$day] * 1), array("user_id" => $UserInfo['user_id'], "uniacid" => $_W["uniacid"]));
		}
		$result = pdo_insert($this->modulename . "_user_creditlogs", array("user_id" => $UserInfo['user_id'],"openid" => $UserInfo['openid'],"unionid" => $UserInfo['unionid'],"uniacid" => $_W["uniacid"], "last_num" => $UserInfo['credit'], "system_id" => $settings['system_id'], "num" => $settings['signin_'.$day] * 1, "create_time" => $_W["timestamp"], "reason" => '签到双倍积分'));
		if($result){
			$record = array("uniacid" => $_W["uniacid"],"system_id" => $UserInfo['system_id'],"user_id" => $UserInfo['user_id'],"openid" => $UserInfo['openid'],"unionid" => $UserInfo['unionid'], "addtime" => time(), "type" => 3);
			if (empty($RecordId)) {
				pdo_insert($this->modulename . "_task_temp", $record);
			} else {
				pdo_update($this->modulename . "_task_temp", array("addtime" => time()), array("id" => $RecordId["id"]));
			}
			exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '领取成功')));
		}
	case 'item':
		$item_id = $_GPC["item_id"];
		$detail = pdo_get($this->modulename . "_item", array("item_id" => $item_id));
		$photos = json_decode($detail["photos"], true);
		if (!empty($photos)) {
			foreach ($photos as $key => $val) {
				$photos[$key] = $_W["attachurl"] . $val;
			}
		}
		$detail["photos"] = $photos;
		$details = json_decode($detail["details"], true);
		if (!empty($details)) {
			foreach ($details as $key => $val) {
				$details[$key] = $_W["attachurl"] . $val;
			}
		}
		$detail["details2"] = html_entity_decode($detail["details2"]);
		$detail["details"] = $details;
		$ret = array();
		$ret["detail"] = $detail;
		if($settings['errorcodeid'] == 49){
			var_dump($detail);
		}
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	
	case 'page':
		$page_id = intval($_GPC["page_id"]);
		$detail = pdo_get($this->modulename . "_page", array("page_id" => $page_id,'is_show' => 1));
		if (empty($detail)) {
			exit(json_encode(array("code" => 0, "status" => 0, "msg" => "内容不存在")));
		}
		$ret = array("page" => array("page_id" => $detail["page_id"], "title" => $detail["title"], "name" => $detail["name"], "post_time" => date('Y-m-d H:i',$detail["post_time"]), "thumb" => $_W["attachurl"] . $detail["thumb"], "avatar" => $_W["attachurl"] . $detail["avatar"], "content" => html_entity_decode($detail["content"])));
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case 'pageA':
		$page_id = intval($_GPC["page_id"]);
		$detail = pdo_get($this->modulename . "_page", array("page_id" => $page_id));
		if (empty($detail)) {
			exit(json_encode(array("code" => 0, "status" => 0, "msg" => "内容不存在")));
		}
		$ret = array("page" => array("page_id" => $detail["page_id"], "title" => $detail["title"], "name" => $detail["name"], "post_time" => date('Y-m-d H:i',$detail["post_time"]), "thumb" => $_W["attachurl"] . $detail["thumb"], "avatar" => $_W["attachurl"] . $detail["avatar"], "content" => html_entity_decode($detail["content"])));
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "ranking":
		$condition = "uniacid = {$_W['uniacid']} AND cateid = 41 AND is_show =1 ";
		$orders = " ORDER BY displayorder ASC limit 0,10";
		$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad")." WHERE ".$condition.$orders);
		if($settings['system_type'] == 1){
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
		}else{
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
		}
		
		if($list){
			$resArr['ranking'] = array();
			foreach($list as $k=>$v){
				$nickname = $this->cut_str($v['title'], 1, 0).'****'.$this->cut_str($v['title'], 1, -1);
				$resArr['ranking'][$k] = array('user_id'=>$v['id'],'nickname'=>$nickname,'avatar'=>tomedia($v['thumb']),'invite_sum'=>$v['appid']);
			}
			$resArr['myfans'] = $user['invite_sum'];
			
		}else{
			if($settings['system_type'] == 1){
				$condition = "system_id = {$settings['system_id']} ";
				$orders = " ORDER BY invite_sum DESC limit 0,10";
				$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_user_u")." WHERE ".$condition.$orders);
			}else{
				$condition = "uniacid = {$_W['uniacid']}";
				$orders = " ORDER BY invite_sum DESC limit 0,10";
				$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_user")." WHERE ".$condition.$orders);
			}
			
			$resArr['ranking'] = array();
			foreach($list as $k=>$v){
				$nickname = $this->cut_str($v['nickname'], 1, 0).'****'.$this->cut_str($v['nickname'], 1, -1);
				$resArr['ranking'][$k] = array('user_id'=>$v['user_id'],'nickname'=>$nickname,'avatar'=>$v['avatar'],'invite_sum'=>$v['invite_sum']);
				if($settings['system_type'] == 1){
					if($v['unionid'] == $unionid){
						$resArr['myranking'] = $k+1;
						$resArr['myfans'] = $v['invite_sum'];
					}
				}else{
					if($v['openid'] == $openid){
						$resArr['myranking'] = $k+1;
						$resArr['myfans'] = $v['invite_sum'];
					}
				}
				
			}
			if(!$resArr['myranking']){$resArr['myranking'] = '未上榜';}
			if(!$resArr['myfans']){$resArr['myfans'] = $user['invite_sum'];}
		}
		$ret = array();
		$ret["data"] = $resArr;
		if($settings['errorcodeid'] == 50){
			var_dump($resArr);
		}
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "findorder":
		if($settings['system_type'] == 1){
			$orderno = trim($_GPC["orderno"]);
			$order = pdo_get($this->modulename . "_order_u", array("order_id" => $orderno, "system_id" => $settings['system_id']));
			if($order){
				if($order['order_settlement_time'] > 0){
					$res = 2;
				}else{
					$u = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
					$fee = $this->fee($u['uid'],$_W["uniacid"]);
					if($settings['errorcodeid'] == 51){
						var_dump($fee);
					}
					if($order['pingtai'] == 'meituan'){
						pdo_update($this->modulename . "_order_u", array("c_1" => round($order['order_profit'] * $fee['c_1_fee'] * $settings['meituan_yjrate']/10000,2) , "c_2" => round($order['order_profit'] * $fee['c_2_fee'] * $settings['meituan_yjrate']/10000,2) , "c_3" => round($order['order_profit'] * $fee['c_3_fee'] * $settings['meituan_yjrate']/10000,2) , "c_t" => round($order['order_profit'] * $fee['c_t_fee'] * $settings['meituan_yjrate']/10000,2), "c_2t" => round($order['order_profit'] * $fee['c_2t_fee'] * $settings['meituan_yjrate']/10000,2), "c_1h" => round($order['order_profit'] * $fee['c_1h_fee'] * $settings['meituan_yjrate']/10000,2), "c_2h" => round($order['order_profit'] * $fee['c_2h_fee'] * $settings['meituan_yjrate']/10000,2), "c_3h" => round($order['order_profit'] * $fee['c_3h_fee'] * $settings['meituan_yjrate']/10000,2), "c_4h" => round($order['order_profit'] * $fee['c_4h_fee'] * $settings['meituan_yjrate']/10000,2), "c_1_uid" => $fee['c_1_uid'], "c1_uid" => $fee['c_1_uid'], "c_2_uid" => $fee['c_2_uid'], "c_3_uid" => $fee['c_3_uid'], "c_t_uid" => $fee['c_t_uid'], "c_2t_uid" => $fee['c_2t_uid'], "c_1h_uid" => $fee['c_1h_uid'] , "c_2h_uid" => $fee['c_2h_uid'] , "c_3h_uid" => $fee['c_3h_uid'] , "c_4h_uid" => $fee['c_4h_uid']) , array("id" => $order['id'], "system_id" => $settings['system_id']));
					}elseif($order['pingtai'] == 'elm'){
						pdo_update($this->modulename . "_order_u", array("c_1" => round($order['order_profit'] * $fee['c_1_fee'] * $settings['elm_yjrate']/10000,2) , "c_2" => round($order['order_profit'] * $fee['c_2_fee'] * $settings['elm_yjrate']/10000,2) , "c_3" => round($order['order_profit'] * $fee['c_3_fee'] * $settings['elm_yjrate']/10000,2) , "c_t" => round($order['order_profit'] * $fee['c_t_fee'] * $settings['elm_yjrate']/10000,2), "c_2t" => round($order['order_profit'] * $fee['c_2t_fee'] * $settings['elm_yjrate']/10000,2), "c_1h" => round($order['order_profit'] * $fee['c_1h_fee'] * $settings['elm_yjrate']/10000,2), "c_2h" => round($order['order_profit'] * $fee['c_2h_fee'] * $settings['elm_yjrate']/10000,2), "c_3h" => round($order['order_profit'] * $fee['c_3h_fee'] * $settings['elm_yjrate']/10000,2), "c_4h" => round($order['order_profit'] * $fee['c_4h_fee'] * $settings['elm_yjrate']/10000,2), "c_1_uid" => $fee['c_1_uid'], "c1_uid" => $fee['c_1_uid'], "c_2_uid" => $fee['c_2_uid'], "c_3_uid" => $fee['c_3_uid'], "c_t_uid" => $fee['c_t_uid'], "c_2t_uid" => $fee['c_2t_uid'], "c_1h_uid" => $fee['c_1h_uid'] , "c_2h_uid" => $fee['c_2h_uid'] , "c_3h_uid" => $fee['c_3h_uid'] , "c_4h_uid" => $fee['c_4h_uid']) , array("id" => $order['id'], "system_id" => $settings['system_id']));
					}
					$res = 1;
				}
				
			}else{
				$res = 0;
			}
		}else{
			$orderno = trim($_GPC["orderno"]);
			$order = pdo_get($this->modulename . "_order", array("order_id" => $orderno, "uniacid" => $_W["uniacid"]));
			if($order){
				if($order['order_settlement_time'] > 0){
					$res = 2;
				}else{
					$u = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
					$fee = $this->fee($u['uid'],$_W["uniacid"]);
					if($settings['errorcodeid'] == 52){
						var_dump($fee);
					}
					if($order['pingtai'] == 'meituan'){
						pdo_update($this->modulename . "_order", array("c_1" => round($order['order_profit'] * $fee['c_1_fee'] * $settings['meituan_yjrate']/10000,2) , "c_2" => round($order['order_profit'] * $fee['c_2_fee'] * $settings['meituan_yjrate']/10000,2) , "c_3" => round($order['order_profit'] * $fee['c_3_fee'] * $settings['meituan_yjrate']/10000,2) , "c_t" => round($order['order_profit'] * $fee['c_t_fee'] * $settings['meituan_yjrate']/10000,2), "c_2t" => round($order['order_profit'] * $fee['c_2t_fee'] * $settings['meituan_yjrate']/10000,2), "c_1h" => round($order['order_profit'] * $fee['c_1h_fee'] * $settings['meituan_yjrate']/10000,2), "c_2h" => round($order['order_profit'] * $fee['c_2h_fee'] * $settings['meituan_yjrate']/10000,2), "c_3h" => round($order['order_profit'] * $fee['c_3h_fee'] * $settings['meituan_yjrate']/10000,2), "c_4h" => round($order['order_profit'] * $fee['c_4h_fee'] * $settings['meituan_yjrate']/10000,2), "c_1_uid" => $fee['c_1_uid'], "c1_uid" => $fee['c_1_uid'], "c_2_uid" => $fee['c_2_uid'], "c_3_uid" => $fee['c_3_uid'], "c_t_uid" => $fee['c_t_uid'], "c_2t_uid" => $fee['c_2t_uid'], "c_1h_uid" => $fee['c_1h_uid'] , "c_2h_uid" => $fee['c_2h_uid'] , "c_3h_uid" => $fee['c_3h_uid'] , "c_4h_uid" => $fee['c_4h_uid']) , array("id" => $order['id'], "uniacid" => $_W["uniacid"]));
					}elseif($order['pingtai'] == 'elm'){
						pdo_update($this->modulename . "_order", array("c_1" => round($order['order_profit'] * $fee['c_1_fee'] * $settings['elm_yjrate']/10000,2) , "c_2" => round($order['order_profit'] * $fee['c_2_fee'] * $settings['elm_yjrate']/10000,2) , "c_3" => round($order['order_profit'] * $fee['c_3_fee'] * $settings['elm_yjrate']/10000,2) , "c_t" => round($order['order_profit'] * $fee['c_t_fee'] * $settings['elm_yjrate']/10000,2), "c_2t" => round($order['order_profit'] * $fee['c_2t_fee'] * $settings['elm_yjrate']/10000,2), "c_1h" => round($order['order_profit'] * $fee['c_1h_fee'] * $settings['elm_yjrate']/10000,2), "c_2h" => round($order['order_profit'] * $fee['c_2h_fee'] * $settings['elm_yjrate']/10000,2), "c_3h" => round($order['order_profit'] * $fee['c_3h_fee'] * $settings['elm_yjrate']/10000,2), "c_4h" => round($order['order_profit'] * $fee['c_4h_fee'] * $settings['elm_yjrate']/10000,2), "c_1_uid" => $fee['c_1_uid'], "c1_uid" => $fee['c_1_uid'], "c_2_uid" => $fee['c_2_uid'], "c_3_uid" => $fee['c_3_uid'], "c_t_uid" => $fee['c_t_uid'], "c_2t_uid" => $fee['c_2t_uid'], "c_1h_uid" => $fee['c_1h_uid'] , "c_2h_uid" => $fee['c_2h_uid'] , "c_3h_uid" => $fee['c_3h_uid'] , "c_4h_uid" => $fee['c_4h_uid']) , array("id" => $order['id'], "uniacid" => $_W["uniacid"]));
					}
					$res = 1;
					if($settings['errorcodeid'] == 53){
						pdo_debug();die();
					}
				}
				
			}else{
				$res = 0;
			}
		}
		
		$ret["data"] = $res;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "orders":
		$type = trim($_GPC["type"]);
		$status = trim($_GPC["status"]);
		$page = intval($_GPC["page"]);
		if(!$type or !$status or !$page){
			$ret = array();
			$ret["orders"] = $feeds;
			$ret["total"] = ceil($total / $psize);
			$ret = json_encode($ret);
			$data = array();
			$data["key"] = substr(md5(time() . uniqid()), 0, 16);
			$data["data"] = $this->aesEn($ret, $data["key"]);
			exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
		}
		if($settings['system_type'] == 1){
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
		}else{
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
		}
		
		$psize = 10;
		$pindex = max(1, intval($_GPC["page"]));
		if($settings['system_type'] == 1){
			$condition = " WHERE system_id = ".$settings['system_id'];
			if($status == '全部'){
				if($type == 'wjs'){
					$condition .= " AND (c_1_uid = '" . $user['uid'] . "' or c_2_uid = '" . $user['uid'] . "' or c_3_uid = '" . $user['uid'] . "' or c_t_uid = '" . $user['uid'] . "' or c_2t_uid = '" . $user['uid'] . "' or c_1h_uid = '" . $user['uid'] . "' or c_2h_uid = '" . $user['uid'] . "' or c_3h_uid = '" . $user['uid'] . "' or c_4h_uid = '" . $user['uid'] . "') AND order_status <> 8 AND order_status <> 3 AND order_status <> 103  ";
				}elseif($type == 'yjs'){
					$condition .= " AND (c_1_uid = '" . $user['uid'] . "' or c_2_uid = '" . $user['uid'] . "' or c_3_uid = '" . $user['uid'] . "' or c_t_uid = '" . $user['uid'] . "' or c_2t_uid = '" . $user['uid'] . "' or c_1h_uid = '" . $user['uid'] . "' or c_2h_uid = '" . $user['uid'] . "' or c_3h_uid = '" . $user['uid'] . "' or c_4h_uid = '" . $user['uid'] . "') AND (order_status = 8  or order_status = 3 or order_status = 103) ";
				}elseif($type == 'today'){
					$condition .= " AND (c_1_uid = '" . $user['uid'] . "' or c_2_uid = '" . $user['uid'] . "' or c_3_uid = '" . $user['uid'] . "' or c_t_uid = '" . $user['uid'] . "' or c_2t_uid = '" . $user['uid'] . "' or c_1h_uid = '" . $user['uid'] . "' or c_2h_uid = '" . $user['uid'] . "' or c_3h_uid = '" . $user['uid'] . "' or c_4h_uid = '" . $user['uid'] . "') AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND order_paid_time > ".strtotime(date("Y-m-d"),time());
				}elseif($type == 'month'){
					$condition .= " AND (c_1_uid = '" . $user['uid'] . "' or c_2_uid = '" . $user['uid'] . "' or c_3_uid = '" . $user['uid'] . "' or c_t_uid = '" . $user['uid'] . "' or c_2t_uid = '" . $user['uid'] . "' or c_1h_uid = '" . $user['uid'] . "' or c_2h_uid = '" . $user['uid'] . "' or c_3h_uid = '" . $user['uid'] . "' or c_4h_uid = '" . $user['uid'] . "') AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND order_paid_time > ".mktime(0,0,0,date('m'),1,date('Y'));
				}elseif($type == 'lastmonth'){
					$condition .= " AND (c_1_uid = '" . $user['uid'] . "' or c_2_uid = '" . $user['uid'] . "' or c_3_uid = '" . $user['uid'] . "' or c_t_uid = '" . $user['uid'] . "' or c_2t_uid = '" . $user['uid'] . "' or c_1h_uid = '" . $user['uid'] . "' or c_2h_uid = '" . $user['uid'] . "' or c_3h_uid = '" . $user['uid'] . "' or c_4h_uid = '" . $user['uid'] . "') AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND order_paid_time > ".strtotime(date('Y-m-01', (strtotime(date('Y-m')) - 1))) ." AND order_paid_time > ".strtotime(date('Y-m-01', (strtotime(date('Y-m')) - 1))) .' AND order_paid_time < '.mktime(0,0,0,date('m'),1,date('Y'));
				}
			}

			if($status == '已付款'){
				$condition .= " AND (order_status = 12  or order_status = 1  or order_status = 101) ";
			}
			if($status == '已完成'){
				$condition .= " AND (order_status = 8 or order_status = 3 or order_status = 14 or order_status = 102) ";
			}
			if($status == '已取消'){
				$condition .= " AND (order_status = 9 or order_status = 13 or order_status = 100 or order_status = 104) ";
			}
			if($type == 'my'){
				$condition .= " AND c_1_uid = '" . $user['uid'] . "' ";
			}
			if($type == 'fans'){
				$condition .= " AND (c_2_uid = '" . $user['uid'] . "' or c_3_uid = '" . $user['uid'] . "' or c_t_uid = '" . $user['uid'] . "' or c_2t_uid = '" . $user['uid'] . "' or c_1h_uid = '" . $user['uid'] . "' or c_2h_uid = '" . $user['uid'] . "' or c_3h_uid = '" . $user['uid'] . "' or c_4h_uid = '" . $user['uid'] . "') ";
			}
			$orderby = " ORDER BY id DESC ";
			$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_order_u") . $condition . $orderby . " LIMIT " . ($pindex - 1) * $psize . "," . $psize);
			$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_order_u") . $condition);

		}else{
			$condition = " WHERE uniacid = {$_W['uniacid']} ";
			if($status == '全部'){
				if($type == 'wjs'){
					$condition .= " AND (c_1_uid = '" . $user['uid'] . "' or c_2_uid = '" . $user['uid'] . "' or c_3_uid = '" . $user['uid'] . "' or c_t_uid = '" . $user['uid'] . "' or c_2t_uid = '" . $user['uid'] . "' or c_1h_uid = '" . $user['uid'] . "' or c_2h_uid = '" . $user['uid'] . "' or c_3h_uid = '" . $user['uid'] . "' or c_4h_uid = '" . $user['uid'] . "') AND order_status <> 8 AND order_status <> 3 AND order_status <> 103 ";
				}elseif($type == 'yjs'){
					$condition .= " AND (c_1_uid = '" . $user['uid'] . "' or c_2_uid = '" . $user['uid'] . "' or c_3_uid = '" . $user['uid'] . "' or c_t_uid = '" . $user['uid'] . "' or c_2t_uid = '" . $user['uid'] . "' or c_1h_uid = '" . $user['uid'] . "' or c_2h_uid = '" . $user['uid'] . "' or c_3h_uid = '" . $user['uid'] . "' or c_4h_uid = '" . $user['uid'] . "') AND (order_status = 8  or order_status = 3 or order_status = 103) ";
				}elseif($type == 'today'){
					$condition .= " AND (c_1_uid = '" . $user['uid'] . "' or c_2_uid = '" . $user['uid'] . "' or c_3_uid = '" . $user['uid'] . "' or c_t_uid = '" . $user['uid'] . "' or c_2t_uid = '" . $user['uid'] . "' or c_1h_uid = '" . $user['uid'] . "' or c_2h_uid = '" . $user['uid'] . "' or c_3h_uid = '" . $user['uid'] . "' or c_4h_uid = '" . $user['uid'] . "') AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND order_paid_time > ".strtotime(date("Y-m-d"),time());
				}elseif($type == 'month'){
					$condition .= " AND (c_1_uid = '" . $user['uid'] . "' or c_2_uid = '" . $user['uid'] . "' or c_3_uid = '" . $user['uid'] . "' or c_t_uid = '" . $user['uid'] . "' or c_2t_uid = '" . $user['uid'] . "' or c_1h_uid = '" . $user['uid'] . "' or c_2h_uid = '" . $user['uid'] . "' or c_3h_uid = '" . $user['uid'] . "' or c_4h_uid = '" . $user['uid'] . "') AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND order_paid_time > ".mktime(0,0,0,date('m'),1,date('Y'));
				}elseif($type == 'lastmonth'){
					$condition .= " AND (c_1_uid = '" . $user['uid'] . "' or c_2_uid = '" . $user['uid'] . "' or c_3_uid = '" . $user['uid'] . "' or c_t_uid = '" . $user['uid'] . "' or c_2t_uid = '" . $user['uid'] . "' or c_1h_uid = '" . $user['uid'] . "' or c_2h_uid = '" . $user['uid'] . "' or c_3h_uid = '" . $user['uid'] . "' or c_4h_uid = '" . $user['uid'] . "') AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND order_paid_time > ".strtotime(date('Y-m-01', (strtotime(date('Y-m')) - 1))) .' AND order_paid_time < '.mktime(0,0,0,date('m'),1,date('Y'));
				}
			}

			if($status == '已付款'){
				$condition .= " AND (order_status = 12  or order_status = 1 or order_status = 101) ";
			}
			if($status == '已完成'){
				$condition .= " AND (order_status = 8 or order_status = 3 or order_status = 14 or order_status = 102) ";
			}
			if($status == '已取消'){
				$condition .= " AND (order_status = 9 or order_status = 13 or order_status = 100 or order_status = 104) ";
			}
			if($type == 'my'){
				$condition .= " AND c_1_uid = '" . $user['uid'] . "' ";
			}
			if($type == 'fans'){
				$condition .= " AND (c_2_uid = '" . $user['uid'] . "' or c_3_uid = '" . $user['uid'] . "' or c_t_uid = '" . $user['uid'] . "' or c_2t_uid = '" . $user['uid'] . "' or c_1h_uid = '" . $user['uid'] . "' or c_2h_uid = '" . $user['uid'] . "' or c_3h_uid = '" . $user['uid'] . "' or c_4h_uid = '" . $user['uid'] . "') ";
			}
			$orderby = " ORDER BY id DESC ";
			$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_order") . $condition . $orderby . " LIMIT " . ($pindex - 1) * $psize . "," . $psize);
			$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_order") . $condition);
		}
		$orders = array();
		foreach ($list as $key => $val) {
			$fee1 = 0;$fee2 = 0;$fee3 = 0;$fee4 = 0;
			if($val['pingtai'] == 'meituan'){$shopName = '美团商家';$goods_img = '../../../static/images/takeout/logo-mt.png';}
			if($val['pingtai'] == 'fenxiao'){$shopName = '美团商家';$goods_img = '../../../static/images/takeout/logo-mt.png';}
			if($val['pingtai'] == 'elm'){$shopName = '饿了么商家';$goods_img = '../../../static/images/takeout/logo-elm.png';}
			if($val['pingtai'] == 'movie'){$shopName = '电影票';$goods_img = $val["goods_img"];}
			if($val['pingtai'] == 'meituan' && $val['order_type'] == 4){$shopName = '美团外卖商家';$goods_img = '../../../static/images/takeout/logo-mt.png';}
			if($val['pingtai'] == 'meituan' && $val['order_type'] == 6){$shopName = '美团闪购商家';$goods_img = '../../../static/images/takeout/logo-mtsc.png';}
			if($val['pingtai'] == 'elm' && $val["shopname"]){$shopName = $val["shopname"];$goods_img = $val["goods_img"];}

			if($val["order_paid_time"]){
				$order_date = date('Y-m-d H:i',$val["order_paid_time"]);
			}else{
				$order_date = '';
			}
			if($val["order_status"] == 9 || $val["order_status"] == 13){
				$desc = '(已取消)';
			}else{
				$desc = '';
			}

			if($val["c_1_uid"] == $user['uid']){$fee1 = $val["c_1"];$ji = '自购';}
			if($val["c_2_uid"] == $user['uid']){$fee2 = $val["c_2"];$ji = '直推';}
			if($val["c_3_uid"] == $user['uid']){$fee3 = $val["c_3"];$ji = '间推';}
			if($val["c_t_uid"] == $user['uid']){$fee4 = $val["c_t"];$ji = '团长';}
			if($val["c_2t_uid"] == $user['uid']){$fee5 = $val["c_2t"];$ji = '团长';}
			if($val["c_1h_uid"] == $user['uid']){$fee6 = $val["c_1h"];$ji = '合伙人';}
			if($val["c_2h_uid"] == $user['uid']){$fee7 = $val["c_2h"];$ji = '合伙人';}
			if($val["c_3h_uid"] == $user['uid']){$fee8 = $val["c_3h"];$ji = '合伙人';}
			if($val["c_4h_uid"] == $user['uid']){$fee9 = $val["c_4h"];$ji = '合伙人';}
			$fee = round($fee1 + $fee2 + $fee3 + $fee4 + $fee5 + $fee6 + $fee7 + $fee8 + $fee9,2);
			$goods_price = $val["order_price"];

			if($type == 'fans'){
				$val["order_id"] = $this->cut_str($val["order_id"], 4, 0).'****'.$this->cut_str($val["order_id"], 4, -4);
			}
			$orders[] = array("id" => $val["id"], "orderNumber" => $val["order_id"], "pingtai" => $val["pingtai"], "shopName" => $shopName, "goods_name" => $val["goods_title"].$desc, "goods_img" => $goods_img, "goods_price" => $goods_price, "fee" => $fee, "orderDate" => $order_date, "ji" => $ji);
		}
		$ret = array();
		$ret["orders"] = $orders;
		if($settings['errorcodeid'] == 54){
			var_dump($orders);
		}
		$ret["total"] = ceil($total / $psize);
		if($ret["total"]>$page){$ret["status"] = 'ok';}
		if($ret["total"]<=$page){$ret["status"] = 'nomore';}
		if($ret["total"] == 0){$ret["status"] = 'empty';}
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case 'movieorderdetail':
		$orderid = $_GPC["orderid"];
		if($settings['system_type'] == 1){
			$detail = pdo_get($this->modulename . "_movieorder", array("id" => $orderid,"unionid" => $unionid));
		}else{
			$detail = pdo_get($this->modulename . "_movieorder", array("id" => $orderid,"openid" => $openid));
		}
		if(strpos($settings['movie_ticket_adminopenid'],$openid) !== false){
			$detail = pdo_get($this->modulename . "_movieorder", array("id" => $orderid));
		}
		if(empty($detail)){
			if($settings['system_type'] == 1){
				$detail = pdo_fetch("SELECT * FROM " . tablename($this->modulename . "_movieorder") . " WHERE thirdOrderId like '%". $orderid . "%' AND unionid = '".$unionid."'");
			}else{
				$detail = pdo_fetch("SELECT * FROM " . tablename($this->modulename . "_movieorder") . " WHERE thirdOrderId like '%". $orderid . "%' AND openid = '".$openid."'");
			}
			if(strpos($settings['movie_ticket_adminopenid'],$openid) !== false){
				$detail = pdo_fetch("SELECT * FROM " . tablename($this->modulename . "_movieorder") . " WHERE thirdOrderId like '%". $orderid . "%'");
			}
			if(empty($detail)){
				exit(json_encode(array('code' => 100, 'status' => 1, 'msg' => '订单不存在，如有疑问请联系客服。')));
			}
		}
		
		$time = time();
		$data = array("appKey" => $settings['movie_api_s_appKey'], "time" => $time, "thirdOrderId" => $detail['thirdOrderId']);
		$sign = $this->get_sign($data, $settings['movie_api_s_appSecret']);
		$data["sign"] = $sign;
		$url = $settings['movie_api_s_url'] . "api/order/query";
		$res = ihttp_request($url, json_encode($data), array("CURLOPT_HTTPHEADER" => array("Content-Type: application/json;charset=utf-8")));
		if($settings['errorcodeid'] == 36){
			var_dump($res);
		}
		$res = json_decode($res["content"], true);
		$detail["ticketCode"] = json_decode($detail["ticketCode"],true);
		$detail["ticketImage"] = json_decode($detail["ticketImage"],true);
		if($res['code'] == 200){
			$detail["orderStatus"] = $res['data']['orderStatus'];
			$detail["realSeat"] = $res['data']['seat'];
			$detail["seat"] = $res['data']['seat'];
			$detail["ticketCode"] = [];
		    $detail["ticketImage"] = [];
			foreach ($res['data']['ticketCode'] as $key => $val) {
				if($val['type'] == 1){
					$detail["ticketCode"][] = $val['code'];
				}elseif($val['type'] == 2){
					$detail["ticketImage"][] = $val['url'];
				}
			}
		}else{
			foreach ($detail["ticketImage"] as $key => $val) {
				$detailtemp["ticketImage"][] = tomedia($val);
			}
			$detail["ticketImage"] = $detailtemp["ticketImage"];
		}
		$detail["pay_time"] = date('Y-m-d H:i:s',$detail['pay_time']);
		$ret = array();
		$ret["detail"] = $detail;
		
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case 'creditorderdetail':
		$orderid = intval($_GPC["orderid"]);
		if($settings['system_type'] == 1){
			$detail = pdo_get($this->modulename . "_item_order", array("order_id" => $orderid,"unionid" => $unionid));
		}else{
			$detail = pdo_get($this->modulename . "_item_order", array("order_id" => $orderid,"openid" => $openid));
		}
		$itemdetail = pdo_get($this->modulename . "_item", array("item_id" => $detail['item_id']));
		$photos = json_decode($itemdetail["photos"], true);
		if (!empty($photos)) {
			$photo = $_W["attachurl"] . $photos[0];
		}
		$detail["photo"] = $photo;
		$detail["title"] = $itemdetail['title'];
		$detail["item_price"] = $itemdetail['price'];
		$detail["is_matter"] = $itemdetail['is_matter'];
		$detail["create_time"] = $detail['create_time'] ? date('Y-m-d H:i:s',$detail['create_time']) : 0;
		$detail["delivery_time"] = $detail['delivery_time'] ? date('Y-m-d H:i:s',$detail['delivery_time']) : 0;
		$detail["complete_time"] = $detail['complete_time'] ? date('Y-m-d H:i:s',$detail['complete_time']) : 0;
		$detail["status"] = $detail['is_over'];
		$ret = array();
		$ret["detail"] = $detail;
		
		if($settings['errorcodeid'] == 49){
			var_dump($detail);
		}
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case 'creditordersh':
		$orderid = intval($_GPC["orderid"]);
		if($settings['system_type'] == 1){
			$detail = pdo_get($this->modulename . "_item_order", array("id" => $orderid,"unionid" => $unionid));
		}else{
			$detail = pdo_get($this->modulename . "_item_order", array("id" => $orderid,"openid" => $openid));
		}
		$res = pdo_update($this->modulename . "_item_order", array("is_over" => 2,"complete_time" => time()), array("order_id" => $orderid));
		$ret = array();
		if($res){
			$ret["shstatus"] = 1;
		}else{
			$ret["shstatus"] = 0;
		}
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "movieorders":
		$type = trim($_GPC["type"]);
		$status = trim($_GPC["status"]);
		$page = intval($_GPC["page"]);
		
		$psize = 10;
		$pindex = max(1, intval($_GPC["page"]));
		if($settings['system_type'] == 1){
			$condition = " WHERE unionid = '".$unionid."' AND system_id = ".$settings['system_id'];
		}else{
			$condition = " WHERE openid = '".$openid."' AND  uniacid = {$_W['uniacid']}";
		}
		
		if($status == '全部订单'){
			$condition .= " AND pay_status = 1 ";
		}
		if($status == '已出票'){
			$condition .= " AND pay_status = 1 AND (orderStatus = 4  or orderStatus = 5) ";
		}
		if($status == '已取消'){
			$condition .= " AND pay_status = 1 AND orderStatus = 10 ";
		}
		$orderby = " ORDER BY id DESC ";
		$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_movieorder") . $condition . $orderby . " LIMIT " . ($pindex - 1) * $psize . "," . $psize);
		$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_movieorder") . $condition);
	
		$orders = array();
		foreach ($list as $key => $val) {
			if($val["realSeat"]){$val["seat"] = $val["realSeat"];}
			if($val["orderStatus"] == 2){$val["orderStatus"] = 0;}
			if($val["orderStatus"] == 3){$val["orderStatus"] = 0;}
			if($val["orderStatus"] == 4){$val["orderStatus"] = 1;}
			if($val["orderStatus"] == 5){$val["orderStatus"] = 1;}
			if($val["orderStatus"] == 10){$val["orderStatus"] = -2;}
			$orders[] = array("id" => $val["id"], "filmName" => $val["filmName"], "showTime" => $val["showTime"], "cinemaName" => $val["cinemaName"], "hallName" => $val["hallName"], "seat" => $val["seat"], "orderNum" => $val["orderNum"], "orderStatus" => $val["orderStatus"], "filmPic" => $val["filmPic"]);
		}
		$ret = array();
		$ret["orders"] = $orders;
		if($settings['errorcodeid'] == 54){
			var_dump($orders);
		}
		$ret["total"] = ceil($total / $psize);
		if($ret["total"]>$page){$ret["status"] = 'ok';}
		if($ret["total"]<=$page){$ret["status"] = 'nomore';}
		if($ret["total"] == 0){$ret["status"] = 'empty';}
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "creditorders":
		$type = trim($_GPC["type"]);
		$status = trim($_GPC["status"]);
		$page = intval($_GPC["page"]);
		
		$psize = 10;
		$pindex = max(1, intval($_GPC["page"]));
		if($settings['system_type'] == 1){
			$condition = " WHERE unionid = '".$unionid."' AND system_id = ".$settings['system_id'];
		}else{
			$condition = " WHERE openid = '".$openid."' AND  uniacid = {$_W['uniacid']}";
		}
		
		if($status == '全部订单'){
			$condition .= " AND (pay_status = 1 OR market_price = 0) AND 1 = 1 ";
		}
		if($status == '已发货'){
			$condition .= " AND (pay_status = 1 OR market_price = 0) AND is_over = 1 ";
		}
		if($status == '已完成'){
			$condition .= " AND (pay_status = 1 OR market_price = 0) AND is_over = 2 ";
		}
		$orderby = " ORDER BY order_id DESC ";
		$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_item_order") . $condition . $orderby . " LIMIT " . ($pindex - 1) * $psize . "," . $psize);
		$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_item_order") . $condition);
	
		$orders = array();
		foreach ($list as $key => $val) {
			$detail = pdo_get($this->modulename . "_item", array("item_id" => $val['item_id']));
			$photos = json_decode($detail["photos"], true);
			if (!empty($photos)) {
				$photo = $_W["attachurl"] . $photos[0];
			}
			$detail["photos"] = $photos;
			$orders[] = array("id" => $val["order_id"],"orderid" => $val["orderid"], "goods_name" => $detail["title"], "goods_img" => $photo, "goods_price" => $detail["price"], "mprice" => $val["market_price"], "goods_buynum" => $val["num"], "status" => $val["is_over"], "orderDate" => date('Y-m-d H:i',$val["create_time"]), "seat" => $val["seat"], "orderNum" => $val["orderNum"], "orderStatus" => $val["orderStatus"], "filmPic" => $val["filmPic"]);
		}
		$ret = array();
		$ret["orders"] = $orders;
		if($settings['errorcodeid'] == 54){
			var_dump($orders);
		}
		$ret["total"] = ceil($total / $psize);
		if($ret["total"]>$page){$ret["status"] = 'ok';}
		if($ret["total"]<=$page){$ret["status"] = 'nomore';}
		if($ret["total"] == 0){$ret["status"] = 'empty';}
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "fans":
		$type = trim($_GPC["type"]);
		$status = trim($_GPC["status"]);
		$page = intval($_GPC["page"]);
		if(!$type or !$status or !$page){
			$ret = array();
			$ret["orders"] = $feeds;
			$ret["total"] = ceil($total / $psize);
			$ret = json_encode($ret);
			$data = array();
			$data["key"] = substr(md5(time() . uniqid()), 0, 16);
			$data["data"] = $this->aesEn($ret, $data["key"]);
			exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
		}
		if($settings['system_type'] == 1){
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
		}else{
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
		}
		
		$psize = 10;
		$pindex = max(1, intval($_GPC["page"]));
		if($settings['system_type'] == 1){
			$condition = " WHERE system_id = ".$settings['system_id'];
			if($type == 'myfans'){
				$condition .= " AND parent_id = '".$user['uid']."'";
			}elseif($type == 'otherfans'){
				$condition .= " AND parent_id <> '".$user['uid']."' AND invite_uid like '%_".$user['uid']."%' ";
			}
			$orderby = " ORDER BY create_time DESC ";
			$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_user_u") . $condition . $orderby . " LIMIT " . ($pindex - 1) * $psize . "," . $psize);
			$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_user_u") . $condition);
		}else{
			$condition = " WHERE uniacid = {$_W['uniacid']} ";
			if($type == 'myfans'){
				$condition .= " AND parent_id = ".$user['uid'];
			}elseif($type == 'otherfans'){
				$condition .= " AND parent_id <> ".$user['uid']." AND invite_uid like '%_".$user['uid']."%' ";
			}
			$orderby = " ORDER BY create_time DESC ";
			$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_user") . $condition . $orderby . " LIMIT " . ($pindex - 1) * $psize . "," . $psize);
			$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_user") . $condition);
		}
		
		$orders = array();
		foreach ($list as $key => $val) {
			if(!$val["avatar"]){
				$val["avatar"] = '../../static/images/icon_nopic.png';
			}
			if(!$val["nickname"]){
				$val["nickname"] = '未登录用户';
			}
			$orders[] = array("id" => $val["user_id"], "uid" => $val["uid"], "nickname" => $val["nickname"], "avatar" => $val["avatar"], "create_time" => date('Y-m-d H:i',$val["create_time"]));
		}
		$ret = array();
		$ret["orders"] = $orders;
		if($settings['errorcodeid'] == 55){
			var_dump($orders);
		}
		$ret["total"] = ceil($total / $psize);
		if($ret["total"]>$page){$ret["status"] = 'ok';}
		if($ret["total"]<=$page){$ret["status"] = 'nomore';}
		if($ret["total"] == 0){$ret["status"] = 'empty';}
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => $condition, 'data' => $data)));
	case "user_income":
		if($settings['system_type'] == 1){
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
		}else{
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
		}
		
		if($settings['system_type'] == 1){
			$uniacid1 = 'system_id';
			$uniacid2 = $settings['system_id'];
			$table = '_u';
			$c_1_uid = 'c_1_uid';
			$c_2_uid = 'c_2_uid';
			$c_3_uid = 'c_3_uid';
			$c_t_uid = 'c_t_uid';
			$c_2t_uid = 'c_2t_uid';
			$c_1h_uid = 'c_1h_uid';
			$c_2h_uid = 'c_2h_uid';
			$c_3h_uid = 'c_3h_uid';
			$c_4h_uid = 'c_4h_uid';
		}else{
			$uniacid1 = 'uniacid';
			$uniacid2 = $_W['uniacid'];
			$table = '';
			$c_1_uid = 'c_1_uid';
			$c_2_uid = 'c_2_uid';
			$c_3_uid = 'c_3_uid';
			$c_t_uid = 'c_t_uid';
			$c_2t_uid = 'c_2t_uid';
			$c_1h_uid = 'c_1h_uid';
			$c_2h_uid = 'c_2h_uid';
			$c_3h_uid = 'c_3h_uid';
			$c_4h_uid = 'c_4h_uid';
		}
		//今日预估收益
		$today_c_1_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_1_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date("Y-m-d"),time());
		$today_c_1 = pdo_fetchall("SELECT SUM(c_1) as c_1 FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$today_c_1_c);

		$today_c_2_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_2_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date("Y-m-d"),time());
		$today_c_2 = pdo_fetchall("SELECT SUM(c_2) as c_2 FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$today_c_2_c);

		$today_c_3_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_3_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date("Y-m-d"),time());
		$today_c_3 = pdo_fetchall("SELECT SUM(c_3) as c_3 FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$today_c_3_c);

		$today_c_t_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_t_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date("Y-m-d"),time());
		$today_c_t = pdo_fetchall("SELECT SUM(c_t) as c_t FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$today_c_t_c);

		$today_c_2t_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_2t_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date("Y-m-d"),time());
		$today_c_2t = pdo_fetchall("SELECT SUM(c_2t) as c_2t FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$today_c_2t_c);

		$today_c_1h_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_1h_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date("Y-m-d"),time());
		$today_c_1h = pdo_fetchall("SELECT SUM(c_1h) as c_1h FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$today_c_1h_c);

		$today_c_2h_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_2h_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date("Y-m-d"),time());
		$today_c_2h = pdo_fetchall("SELECT SUM(c_2h) as c_2h FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$today_c_2h_c);

		$today_c_3h_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_3h_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date("Y-m-d"),time());
		$today_c_3h = pdo_fetchall("SELECT SUM(c_3h) as c_3h FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$today_c_3h_c);

		$today_c_4h_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_4h_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date("Y-m-d"),time());
		$today_c_4h = pdo_fetchall("SELECT SUM(c_4h) as c_4h FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$today_c_4h_c);

		$today = round($today_c_1[0]['c_1'] + $today_c_2[0]['c_2'] +$today_c_3[0]['c_3'] +$today_c_t[0]['c_t'] +$today_c_2t[0]['c_2t'] +$today_c_1h[0]['c_1h'] +$today_c_2h[0]['c_2h'] +$today_c_3h[0]['c_3h'] +$today_c_4h[0]['c_4h'],2); 

		//本月预估收益
		$month_c_1_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_1_uid} = {$user['uid']} AND order_paid_time > ".mktime(0,0,0,date('m'),1,date('Y'));
		$month_c_1 = pdo_fetchall("SELECT SUM(c_1) as c_1 FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$month_c_1_c);

		$month_c_2_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_2_uid} = {$user['uid']} AND order_paid_time > ".mktime(0,0,0,date('m'),1,date('Y'));
		$month_c_2 = pdo_fetchall("SELECT SUM(c_2) as c_2 FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$month_c_2_c);

		$month_c_3_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_3_uid} = {$user['uid']} AND order_paid_time > ".mktime(0,0,0,date('m'),1,date('Y'));
		$month_c_3 = pdo_fetchall("SELECT SUM(c_3) as c_3 FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$month_c_3_c);

		$month_c_t_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_t_uid} = {$user['uid']} AND order_paid_time > ".mktime(0,0,0,date('m'),1,date('Y'));
		$month_c_t = pdo_fetchall("SELECT SUM(c_t) as c_t FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$month_c_t_c);

		$month_c_2t_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_2t_uid} = {$user['uid']} AND order_paid_time > ".mktime(0,0,0,date('m'),1,date('Y'));
		$month_c_2t = pdo_fetchall("SELECT SUM(c_2t) as c_2t FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$month_c_2t_c);

		$month_c_1h_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_1h_uid} = {$user['uid']} AND order_paid_time > ".mktime(0,0,0,date('m'),1,date('Y'));
		$month_c_1h = pdo_fetchall("SELECT SUM(c_1h) as c_1h FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$month_c_1h_c);

		$month_c_2h_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_2h_uid} = {$user['uid']} AND order_paid_time > ".mktime(0,0,0,date('m'),1,date('Y'));
		$month_c_2h = pdo_fetchall("SELECT SUM(c_2h) as c_2h FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$month_c_2h_c);

		$month_c_3h_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_3h_uid} = {$user['uid']} AND order_paid_time > ".mktime(0,0,0,date('m'),1,date('Y'));
		$month_c_3h = pdo_fetchall("SELECT SUM(c_3h) as c_3h FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$month_c_3h_c);

		$month_c_4h_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_4h_uid} = {$user['uid']} AND order_paid_time > ".mktime(0,0,0,date('m'),1,date('Y'));
		$month_c_4h = pdo_fetchall("SELECT SUM(c_4h) as c_4h FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$month_c_4h_c);

		$month = round($month_c_1[0]['c_1'] + $month_c_2[0]['c_2'] +$month_c_3[0]['c_3'] +$month_c_t[0]['c_t'] +$month_c_2t[0]['c_2t'] +$month_c_1h[0]['c_1h'] +$month_c_2h[0]['c_2h'] +$month_c_3h[0]['c_3h'] +$month_c_4h[0]['c_4h'],2); 


		//上月预估收益
		$last_month_c_1_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_1_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date('Y-m-01', (strtotime(date('Y-m')) - 1))) .' AND order_paid_time < '.mktime(0,0,0,date('m'),1,date('Y'));
		$last_month_c_1 = pdo_fetchall("SELECT SUM(c_1) as c_1 FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$last_month_c_1_c);

		$last_month_c_2_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_2_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date('Y-m-01', (strtotime(date('Y-m')) - 1))) .' AND order_paid_time < '.mktime(0,0,0,date('m'),1,date('Y'));
		$last_month_c_2 = pdo_fetchall("SELECT SUM(c_2) as c_2 FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$last_month_c_2_c);

		$last_month_c_3_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_3_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date('Y-m-01', (strtotime(date('Y-m')) - 1))) .' AND order_paid_time < '.mktime(0,0,0,date('m'),1,date('Y'));
		$last_month_c_3 = pdo_fetchall("SELECT SUM(c_3) as c_3 FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$last_month_c_3_c);

		$last_month_c_t_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_t_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date('Y-m-01', (strtotime(date('Y-m')) - 1))) .' AND order_paid_time < '.mktime(0,0,0,date('m'),1,date('Y'));
		$last_month_c_t = pdo_fetchall("SELECT SUM(c_t) as c_t FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$last_month_c_t_c);

		$last_month_c_2t_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_2t_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date('Y-m-01', (strtotime(date('Y-m')) - 1))) .' AND order_paid_time < '.mktime(0,0,0,date('m'),1,date('Y'));
		$last_month_c_2t = pdo_fetchall("SELECT SUM(c_2t) as c_2t FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$last_month_c_2t_c);

		$last_month_c_1h_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_1h_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date('Y-m-01', (strtotime(date('Y-m')) - 1))) .' AND order_paid_time < '.mktime(0,0,0,date('m'),1,date('Y'));
		$last_month_c_1h = pdo_fetchall("SELECT SUM(c_1h) as c_1h FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$last_month_c_1h_c);

		$last_month_c_2h_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_2h_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date('Y-m-01', (strtotime(date('Y-m')) - 1))) .' AND order_paid_time < '.mktime(0,0,0,date('m'),1,date('Y'));
		$last_month_c_2h = pdo_fetchall("SELECT SUM(c_2h) as c_2h FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$last_month_c_2h_c);

		$last_month_c_3h_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_3h_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date('Y-m-01', (strtotime(date('Y-m')) - 1))) .' AND order_paid_time < '.mktime(0,0,0,date('m'),1,date('Y'));
		$last_month_c_3h = pdo_fetchall("SELECT SUM(c_3h) as c_3h FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$last_month_c_3h_c);

		$last_month_c_4h_c = "{$uniacid1} = {$uniacid2} AND order_status <> 9 AND order_status <> 13 AND order_status <> 100 AND order_status <> 104 AND {$c_4h_uid} = {$user['uid']} AND order_paid_time > ".strtotime(date('Y-m-01', (strtotime(date('Y-m')) - 1))) .' AND order_paid_time < '.mktime(0,0,0,date('m'),1,date('Y'));
		$last_month_c_4h = pdo_fetchall("SELECT SUM(c_4h) as c_4h FROM ".tablename($this->modulename . "_order".$table)." WHERE ".$last_month_c_4h_c);

		$last_month = round($last_month_c_1[0]['c_1'] + $last_month_c_2[0]['c_2'] +$last_month_c_3[0]['c_3'] +$last_month_c_t[0]['c_t'] +$last_month_c_2t[0]['c_2t'] +$last_month_c_1h[0]['c_1h'] +$last_month_c_2h[0]['c_2h'] +$last_month_c_3h[0]['c_3h'] +$last_month_c_4h[0]['c_4h'],2);
		
		$resArr =array('today' => $today,'month' => $month,'last_month' => $last_month);

		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "qrcode_mtelm":
		$appid_type = intval($_GPC["appid_type"]);//1为外卖2为商超
		$elmwm_act_id = trim($_GPC["elmwm_act_id"]);
		$type = intval($_GPC["type"]);//1获取链接
		if($settings['system_type'] == 1){
			if($appid_type == 1 || $appid_type == 2){
				$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
				//获取美团推广链接
				if($settings['meituan_api_type'] == 1){
					if($appid_type == 1){
						if(!intval($settings["meituan_waimai_h5_url"])){$settings['meituan_waimai_h5_url'] = 2;}
						if($settings['poster_type'] == 1 && $type == 1){
							$params = array('actId' => $settings['meituan_waimai_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'linkType' => 1,'sign' => 1);
							$meituansign = $this->genSign($params,$settings['meituanapikey']);
							$res = file_get_contents('https://runion.meituan.com/generateLink?actId='.$settings['meituan_waimai_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&linkType=1&sign='.$meituansign);
							if($settings['errorcodeid'] == 56){
								var_dump($res);
							}
						}else{
							$params = array('actId' => $settings['meituan_waimai_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'linkType' => 4,'sign' => 1);
							$meituansign = $this->genSign($params,$settings['meituanapikey']);
							$res = file_get_contents('https://runion.meituan.com/generateLink?actId='.$settings['meituan_waimai_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&linkType=4&sign='.$meituansign);
							if($settings['errorcodeid'] == 57){
								var_dump($res);
							}
						}
						$res = json_decode($res,true);
						if($res['status'] == 0){
							if($settings['poster_type'] == 1 && $type == 1){
								$params = array('actId' => $settings['meituan_waimai_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'sign' => 1);
								$meituansign = $this->genSign($params,$settings['meituanapikey']);
								$rescode = file_get_contents('https://runion.meituan.com/miniCode?actId='.$settings['meituan_waimai_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&sign='.$meituansign);
								if($settings['errorcodeid'] == 58){
									var_dump($rescode);
								}
								$rescode = json_decode($rescode,true);
								$mtwm_url = $res['data'];
								$mtwm_h5 = $settings['waimaitt_meituanwm_tuantext_c'].$res['data'];
								$mtwm_qrcode = str_replace(array("http","https"),"https",$rescode['data']);
							}else{
								$params = array('actId' => $settings['meituan_waimai_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'sign' => 1);
								$meituansign = $this->genSign($params,$settings['meituanapikey']);
								$rescode = file_get_contents('https://runion.meituan.com/miniCode?actId='.$settings['meituan_waimai_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&sign='.$meituansign);
								if($settings['errorcodeid'] == 58){
									var_dump($rescode);
								}
								$rescode = json_decode($rescode,true);
								$mtwm_url = $res['data'];
								$mtwm_h5 = $settings['waimaitt_meituanwm_tuantext_c'].$res['data'];
								$mtwm_qrcode = str_replace(array("http","https"),"https",$rescode['data']);
							}
						}
						$backdata = array('mtwm_url' =>$mtwm_url,'mtwm_h5' => $mtwm_h5,'mtwm_qrcode' => $mtwm_qrcode);
					}elseif($appid_type == 2){
						if(!intval($settings["meituan_sc_h5_url"])){$settings['meituan_sc_h5_url'] = 4;}
						if($settings['poster_type'] == 1 && $type == 1){
							$params = array('actId' => $settings['meituan_sc_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'linkType' => 1,'sign' => 1);
							$meituansign = $this->genSign($params,$settings['meituanapikey']);
							$res = file_get_contents('https://runion.meituan.com/generateLink?actId='.$settings['meituan_sc_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&linkType=1&sign='.$meituansign);
							if($settings['errorcodeid'] == 59){
								var_dump($res);
							}
						}else{
							$params = array('actId' => $settings['meituan_sc_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'linkType' => 4,'sign' => 1);
							$meituansign = $this->genSign($params,$settings['meituanapikey']);
							$res = file_get_contents('https://runion.meituan.com/generateLink?actId='.$settings['meituan_sc_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&linkType=4&sign='.$meituansign);
							if($settings['errorcodeid'] == 60){
								var_dump($res);
							}
						}
						$res = json_decode($res,true);
						if($res['status'] == 0){
							if($settings['poster_type'] == 1 && $type == 1){
								$params = array('actId' => $settings['meituan_sc_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'sign' => 1);
								$meituansign = $this->genSign($params,$settings['meituanapikey']);
								$rescode = file_get_contents('https://runion.meituan.com/miniCode?actId='.$settings['meituan_sc_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&sign='.$meituansign);
								if($settings['errorcodeid'] == 61){
									var_dump($rescode);
								}
								$rescode = json_decode($rescode,true);
								$mtsc_url = $res['data'];
								$mtsc_h5 = $settings['waimaitt_meituansc_tuantext_c'].$res['data'];
								$mtsc_qrcode = str_replace(array("http","https"),"https",$rescode['data']);
							}else{
								$params = array('actId' => $settings['meituan_sc_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'sign' => 1);
								$meituansign = $this->genSign($params,$settings['meituanapikey']);
								$rescode = file_get_contents('https://runion.meituan.com/miniCode?actId='.$settings['meituan_sc_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&sign='.$meituansign);
								if($settings['errorcodeid'] == 61){
									var_dump($rescode);
								}
								$rescode = json_decode($rescode,true);
								$mtsc_url = $res['data'];
								$mtsc_h5 = $settings['waimaitt_meituansc_tuantext_c'].$res['data'];
								$mtsc_qrcode = str_replace(array("http","https"),"https",$rescode['data']);
							}
						}
						$backdata = array('mtsc_url' => $mtsc_url,'mtsc_h5' => $mtsc_h5,'mtsc_qrcode' => $mtsc_qrcode);
					}
				}elseif($settings['meituan_api_type'] == 2){
					if($appid_type == 1){
						$meituan_data["activity"] = $settings['meituangroup_waimai_activity'];
					}elseif($appid_type == 2){
						$meituan_data["activity"] = $settings['meituangroup_sc_activity'];
					}
					$timestamp = time();
					$key = $settings['meituangroup_AppKey'];
					$meituan_data["utmSource"] = $settings['meituangroup_utmSource'];
					$meituan_data["utmMedium"] = $this->aesencrypt($user['uid'],$key);
					pdo_update($this->modulename . "_user", array("utmMedium" => $meituan_data["utmMedium"]), array("openid" => $openid, "uniacid" => $_W["uniacid"]));
					if($settings['system_type'] == 1){
						pdo_update($this->modulename . "_user_u", array("utmMedium" => $meituan_data["utmMedium"]), array("unionid" => $unionid, "system_id" => $settings['system_id']));
					}
					$meituan_data["promotionId"] = $settings['meituangroup_pid'];
					$meituan_data["pageLevel"] = 1;
					$requestId = $meituan_data["utmSource"] . $timestamp;
					$accessToken = $this->aesencrypt($requestId,$key);
					$url = "https://union.dianping.com/api/promotion/link?timestamp=" . $timestamp . "&requestId=" . $requestId . "&utmSource=" . $meituan_data["utmSource"] . "&version=2.0&accessToken=" . $accessToken;
					$res = $this->curlPost($url,$meituan_data);
					if($appid_type == 1){
						$backdata = array('mtwm_url' => $res['data']['miniProgramPath'],'mtwm_h5' => $res['data']['shortLink'],'mtwm_qrcode' => $res['data']['miniProgramQrCode'],'mtwm_apitype' => 2);
					}elseif($appid_type == 2){
						$backdata = array('mtsc_url' => $res['data']['miniProgramPath'],'mtsc_h5' => $res['data']['shortLink'],'mtsc_qrcode' => $res['data']['miniProgramQrCode'],'mtwm_apitype' => 2);
					}
				}else{
					$postdata = http_build_query(array('apikey' => $settings['ddxapikey'],'sid' => $user['uid'],'generate_we_app' => true,'qrcode' => true));
					$options = array(
							'http' => array(
							'method' => 'POST',
							'header' => 'Content-type:application/x-www-form-urlencoded',
							'content' => $postdata,
							'timeout' => 1 * 60 // 超时时间（单位:s）
						  )
						);
					$cxContext = stream_context_create($options);
					if($appid_type == 1){
						//外卖
						$wm = file_get_contents("http://api.tbk.dingdanxia.com/waimai/meituan_privilege", false, $cxContext);
						if($settings['errorcodeid'] == 62){
							var_dump($wm);
						}
						$wm = json_decode($wm,true);
						if($wm['code'] == 200){
							if($settings['poster_type'] == 1 && $type == 1){
								$mtwm_url = $wm['data']['we_app_info']['page_path'];
								$mtwm_h5 = $settings['waimaitt_meituanwm_tuantext_c'].$wm['data']['h5'];
								$mtwm_qrcode = str_replace(array("http","https"),"https",$wm['data']['we_app_info']['miniCode']);
							}else{
								$mtwm_url = $wm['data']['we_app_info']['page_path'];
								$mtwm_h5 = $settings['waimaitt_meituanwm_tuantext_c'].$wm['data']['h5'];
								$mtwm_qrcode = str_replace(array("http","https"),"https",$wm['data']['we_app_info']['miniCode']);
							}
						}else{
							$mtwm_url = '';$mtwm_h5 = '';$mtwm_qrcode = '';
						}
						$backdata = array('mtwm_url' =>$mtwm_url,'mtwm_h5' => $mtwm_h5,'mtwm_qrcode' => $mtwm_qrcode);
					}elseif($appid_type == 2){
						//闪购
						$wm = file_get_contents("http://api.tbk.dingdanxia.com/waimai/meituan_sg_privilege", false, $cxContext);
						if($settings['errorcodeid'] == 63){
								var_dump($wm);
							}
						$wm = json_decode($wm,true);
						if($wm['code'] == 200){
							if($settings['poster_type'] == 1 && $type == 1){
								$mtsc_url = $wm['data']['we_app_info']['page_path'];
								$mtsc_h5 = $settings['waimaitt_meituansc_tuantext_c'].$wm['data']['h5'];
								$mtsc_qrcode = str_replace(array("http","https"),"https",$wm['data']['we_app_info']['miniCode']);
							}else{
								$mtsc_url = $wm['data']['we_app_info']['page_path'];
								$mtsc_h5 = $settings['waimaitt_meituansc_tuantext_c'].$wm['data']['h5'];
								$mtsc_qrcode = str_replace(array("http","https"),"https",$wm['data']['we_app_info']['miniCode']);
							}
						}else{
							$mtsc_url = '';$mtsc_h5 = '';$mtsc_qrcode = '';
						}
						$backdata = array('mtsc_url' => $mtsc_url,'mtsc_qrcode' =>$mtsc_qrcode,'mtsc_h5' =>$mtsc_h5);
					}
				}
				
				//获取美团推广链接
				$ret = json_encode($backdata);
				$data = array();
				$data["key"] = substr(md5(time() . uniqid()), 0, 16);
				$data["data"] = $this->aesEn($ret, $data["key"]);
				exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
			}elseif($appid_type == 3 || $appid_type == 4){
				//查询是否有pid空闲
				$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
				if($user['relation_id']){//如果用户已经绑定渠道id，则使用渠道id
					$relation_id = $user['relation_id'];
					$pid = explode("_",$settings['tbqudaopid']);
					if($appid_type == 3){
						if($elmwm_act_id){
							$settings['elmwm_promotion_scene_id'] = $elmwm_act_id;
						}else{
							if(!$settings['elmwm_promotion_scene_id']){
								$settings['elmwm_promotion_scene_id'] = '1571715733668';
							}
						}
						$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
						if($settings['errorcodeid'] == 64){
							var_dump($elmwm_url);
						}
						if($elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
							if($settings['poster_type'] == 1){
								$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
							}else{
								$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
							}
							
						}else{
							$backdata = array('elmwm_url' =>'','elmwm_qrcode' =>'','elmwm_h5' =>'','is_qudao' =>1,'pid_time' =>$pid_use_time);
						}
					}elseif($appid_type == 4){
						if(!$settings['elmsc_promotion_scene_id']){$settings['elmsc_promotion_scene_id'] = '1585018034441';}
						$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
						if($settings['errorcodeid'] == 65){
							var_dump($elmsc_url);
						}
						if($elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
							if($settings['poster_type'] == 1){
								$backdata = array('elmsc_url' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$settings['waimaitt_elmsc_tuantext_c']."：".$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
							}else{
								$backdata = array('elmsc_url' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
							}
							
						}else{
							$backdata = array('elmsc_url' =>'','elmsc_qrcode' =>'','elmsc_h5' =>'','is_qudao' =>1,'pid_time' =>$pid_use_time);
						}
					}
					$ret = json_encode($backdata);
					$data = array();
					$data["key"] = substr(md5(time() . uniqid()), 0, 16);
					$data["data"] = $this->aesEn($ret, $data["key"]);
					exit(json_encode(array('code' => 0, 'status' => 2, 'msg' => 'SUCCESS', 'data' => $data)));
				}else{//如果没有绑定渠道id，则使用pid
					$pid = pdo_get($this->modulename . "_pid_u", array("unionid" => $unionid,"is_use" => 1, "system_id" => $settings['system_id']));
					if($pid){$pid_use_time = $pid['use_time'];}
					if(!$pid){
						$pid = pdo_get($this->modulename . "_pid_u", array("is_use" => 0, "system_id" => $settings['system_id']));
						$pid_use_time = time();
					}
					//有pid空闲
					if($pid){
						pdo_update($this->modulename . "_pid_u", array("nickname" => $user['nickname'],"openid" => $openid,"unionid" => $user['unionid'],"uid" => $user['user_id'],"is_use" => 1,"use_time" => $pid_use_time,"update_time" => time()), array("id" => $pid['id']));
						pdo_insert($this->modulename . "_pidlog", array("uniacid" => $_W["uniacid"],"pid" => $pid['pid'],"sid" => $pid['sid'],"rid" => $pid['rid'],"nickname" => $user['nickname'],"openid" => $openid,"unionid" => $user['unionid'],"uid" => $user['user_id'],"is_use" => 1,"use_time" => $pid_use_time,"update_time" => time(), "system_id" => $settings['system_id']));
						$pid_array = explode("_",$pid['pid']);
						if($appid_type == 3){
							if($elmwm_act_id){
								$settings['elmwm_promotion_scene_id'] = $elmwm_act_id;
							}else{
								if(!$settings['elmwm_promotion_scene_id']){
									$settings['elmwm_promotion_scene_id'] = '1571715733668';
								}
							}
							if($pid['rid']){
								$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&relation_id='.$pid['rid'].'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
								if($settings['errorcodeid'] == 66){
									var_dump($elmwm_url);
								}
							}else{
								$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?appkey='.$settings['appkey'].'&sid='.$pid['sid'].'&adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&platform=2'),true);
								if($settings['errorcodeid'] == 67){
									var_dump($elmwm_url);
								}
							}
							if($elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
								if($settings['poster_type'] == 1){
									$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
								}else{
									$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
								}
								
							}else{
								$backdata = array('elmwm_url' =>'','elmwm_qrcode' =>'','elmwm_h5' =>'','is_qudao' =>0,'pid_time' =>$pid_use_time);
							}
						}elseif($appid_type == 4){
							if(!$settings['elmsc_promotion_scene_id']){$settings['elmsc_promotion_scene_id'] = '1585018034441';}
							if($pid['rid']){
								$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&relation_id='.$pid['rid'].'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
								if($settings['errorcodeid'] == 68){
									var_dump($elmsc_url);
								}
							}else{
								$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?appkey='.$settings['appkey'].'&sid='.$pid['sid'].'&adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&platform=2'),true);
								if($settings['errorcodeid'] == 69){
									var_dump($elmsc_url);
								}
							}
							if($elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
								if($settings['poster_type'] == 1){
									$backdata = array('elmsc_url' => $elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$settings['waimaitt_elmsc_tuantext_c']."：".$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>0,'pid_time' =>$pid_use_time);
								}else{
									$backdata = array('elmsc_url' => $elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>0,'pid_time' =>$pid_use_time);
								}
								
							}else{
								$backdata = array('elmsc_url' => '','elmsc_qrcode' =>'','elmsc_h5' =>'','is_qudao' =>0,'pid_time' =>$pid_use_time);
							}
						}
						$ret = json_encode($backdata);
						$data = array();
						$data["key"] = substr(md5(time() . uniqid()), 0, 16);
						$data["data"] = $this->aesEn($ret, $data["key"]);
						exit(json_encode(array('code' => 0, 'status' => 2, 'msg' => 'SUCCESS', 'data' => $data)));
					}else{//没有pid空闲，则使用渠道
						$inviter_code = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_sc_invitecode_get.ashx?appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&relation_app=common&code_type=1'),true);
						if($settings['errorcodeid'] == 70){
							var_dump($inviter_code);
						}
						$inviter_code = $inviter_code['tbk_sc_invitecode_get_response']['data']['inviter_code'];
						$qudao_url = 'https://mos.m.taobao.com/inviter/register?inviterCode='.$inviter_code.'&src=pub&app=common&rtag='.$user['uid'].'A'.time();
						$tkl = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_tkl_create.ashx?appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&url='.urlencode($qudao_url)),true);
						if($settings['errorcodeid'] == 71){
							var_dump($tkl);
						}
						if($tkl['status'] == 200){
							$qudaotkl = $tkl['model'];
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => '3&#55357;&#56392;'.$qudaotkl.'打开&#55357;&#56393;淘bao&#55357;&#56392;或点击链接 https://m.tb.cn/h.aaaaaaa 至浏览器[渠道方备案完成后，可为您进行商品/店铺和更多物料的推广]')));
						}else{
							exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '获取渠道信息错误')));
						}
					}
				}
			}
		}else{
			if($appid_type == 1 || $appid_type == 2){
				$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
				//获取美团推广链接
				if($settings['meituan_api_type'] == 1){
					if($appid_type == 1){
						if(!intval($settings["meituan_waimai_h5_url"])){$settings['meituan_waimai_h5_url'] = 2;}
						if($settings['poster_type'] == 1 && $type == 1){
							$params = array('actId' => $settings['meituan_waimai_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'linkType' => 1,'sign' => 1);
							$meituansign = $this->genSign($params,$settings['meituanapikey']);
							$res = file_get_contents('https://runion.meituan.com/generateLink?actId='.$settings['meituan_waimai_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&linkType=1&sign='.$meituansign);
							if($settings['errorcodeid'] == 56){
								var_dump($res);
							}
						}else{
							$params = array('actId' => $settings['meituan_waimai_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'linkType' => 4,'sign' => 1);
							$meituansign = $this->genSign($params,$settings['meituanapikey']);
							$res = file_get_contents('https://runion.meituan.com/generateLink?actId='.$settings['meituan_waimai_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&linkType=4&sign='.$meituansign);
							if($settings['errorcodeid'] == 57){
								var_dump($res);
							}
						}
						$res = json_decode($res,true);
						if($res['status'] == 0){
							if($settings['poster_type'] == 1 && $type == 1){
								$params = array('actId' => $settings['meituan_waimai_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'sign' => 1);
								$meituansign = $this->genSign($params,$settings['meituanapikey']);
								$rescode = file_get_contents('https://runion.meituan.com/miniCode?actId='.$settings['meituan_waimai_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&sign='.$meituansign);
								if($settings['errorcodeid'] == 58){
									var_dump($rescode);
								}
								$rescode = json_decode($rescode,true);
								$mtwm_url = $res['data'];
								$mtwm_h5 = $settings['waimaitt_meituanwm_tuantext_c'].$res['data'];
								$mtwm_qrcode = str_replace(array("http","https"),"https",$rescode['data']);
							}else{
								$mtwm_url = $res['data'];$mtwm_h5 = '';$mtwm_qrcode = '';
							}
						}
						$backdata = array('mtwm_url' =>$mtwm_url,'mtwm_h5' => $mtwm_h5,'mtwm_qrcode' => $mtwm_qrcode);
					}elseif($appid_type == 2){
						if(!intval($settings["meituan_sc_h5_url"])){$settings['meituan_sc_h5_url'] = 4;}
						if($settings['poster_type'] == 1 && $type == 1){
							$params = array('actId' => $settings['meituan_sc_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'linkType' => 1,'sign' => 1);
							$meituansign = $this->genSign($params,$settings['meituanapikey']);
							$res = file_get_contents('https://runion.meituan.com/generateLink?actId='.$settings['meituan_sc_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&linkType=1&sign='.$meituansign);
							if($settings['errorcodeid'] == 59){
								var_dump($res);
							}
						}else{
							$params = array('actId' => $settings['meituan_sc_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'linkType' => 4,'sign' => 1);
							$meituansign = $this->genSign($params,$settings['meituanapikey']);
							$res = file_get_contents('https://runion.meituan.com/generateLink?actId='.$settings['meituan_sc_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&linkType=4&sign='.$meituansign);
							if($settings['errorcodeid'] == 60){
								var_dump($res);
							}
						}
						$res = json_decode($res,true);
						if($res['status'] == 0){
							if($settings['poster_type'] == 1 && $type == 1){
								$params = array('actId' => $settings['meituan_sc_h5_url'],'key' => $settings['meituanappkey'],'sid' => $user['uid'],'sign' => 1);
								$meituansign = $this->genSign($params,$settings['meituanapikey']);
								$rescode = file_get_contents('https://runion.meituan.com/miniCode?actId='.$settings['meituan_sc_h5_url'].'&key='.$settings['meituanappkey'].'&sid='.$user['uid'].'&sign='.$meituansign);
								if($settings['errorcodeid'] == 61){
									var_dump($rescode);
								}
								$rescode = json_decode($rescode,true);
								$mtsc_url = $res['data'];
								$mtsc_h5 = $settings['waimaitt_meituansc_tuantext_c'].$res['data'];
								$mtsc_qrcode = str_replace(array("http","https"),"https",$rescode['data']);
							}else{
								$mtsc_url = $res['data'];$mtsc_h5 = '';$mtsc_qrcode = '';
							}
						}
						$backdata = array('mtsc_url' => $mtsc_url,'mtsc_h5' => $mtsc_h5,'mtsc_qrcode' => $mtsc_qrcode);
					}
				}elseif($settings['meituan_api_type'] == 2){
					if($appid_type == 1){
						$meituan_data["activity"] = $settings['meituangroup_waimai_activity'];
					}elseif($appid_type == 2){
						$meituan_data["activity"] = $settings['meituangroup_sc_activity'];
					}
					$timestamp = time();
					$key = $settings['meituangroup_AppKey'];
					$meituan_data["utmSource"] = $settings['meituangroup_utmSource'];
					$meituan_data["utmMedium"] = $this->aesencrypt($user['uid'],$key);
					pdo_update($this->modulename . "_user", array("utmMedium" => $meituan_data["utmMedium"]), array("openid" => $openid, "uniacid" => $_W["uniacid"]));
					if($settings['system_type'] == 1){
						pdo_update($this->modulename . "_user_u", array("utmMedium" => $meituan_data["utmMedium"]), array("unionid" => $unionid, "system_id" => $settings['system_id']));
					}
					$meituan_data["promotionId"] = $settings['meituangroup_pid'];
					$meituan_data["pageLevel"] = 1;
					$requestId = $meituan_data["utmSource"] . $timestamp;
					$accessToken = $this->aesencrypt($requestId,$key);
					$url = "https://union.dianping.com/api/promotion/link?timestamp=" . $timestamp . "&requestId=" . $requestId . "&utmSource=" . $meituan_data["utmSource"] . "&version=2.0&accessToken=" . $accessToken;
					$res = $this->curlPost($url,$meituan_data);
					if($appid_type == 1){
						$backdata = array('mtwm_url' => $res['data']['miniProgramPath'],'mtwm_h5' => $res['data']['shortLink'],'mtwm_qrcode' => $res['data']['miniProgramQrCode'],'mtwm_apitype' => 2);
					}elseif($appid_type == 2){
						$backdata = array('mtsc_url' => $res['data']['miniProgramPath'],'mtsc_h5' => $res['data']['shortLink'],'mtsc_qrcode' => $res['data']['miniProgramQrCode'],'mtwm_apitype' => 2);
					}
				}else{
					$postdata = http_build_query(array('apikey' => $settings['ddxapikey'],'sid' => $user['uid'],'generate_we_app' => true,'qrcode' => true));
					$options = array(
							'http' => array(
							'method' => 'POST',
							'header' => 'Content-type:application/x-www-form-urlencoded',
							'content' => $postdata,
							'timeout' => 1 * 60 // 超时时间（单位:s）
						  )
						);
					$cxContext = stream_context_create($options);
					if($appid_type == 1){
						//外卖
						$wm = file_get_contents("http://api.tbk.dingdanxia.com/waimai/meituan_privilege", false, $cxContext);
						if($settings['errorcodeid'] == 62){
							var_dump($wm);
						}
						$wm = json_decode($wm,true);
						if($wm['code'] == 200){
							if($settings['poster_type'] == 1 && $type == 1){
								$mtwm_url = $wm['data']['we_app_info']['page_path'];
								$mtwm_h5 = $settings['waimaitt_meituanwm_tuantext_c'].$wm['data']['h5'];
								$mtwm_qrcode = str_replace(array("http","https"),"https",$wm['data']['we_app_info']['miniCode']);
							}else{
								$mtwm_url = $wm['data']['we_app_info']['page_path'];$mtwm_h5 = '';$mtwm_qrcode = '';
							}
						}else{
							$mtwm_url = '';$mtwm_h5 = '';$mtwm_qrcode = '';
						}
						$backdata = array('mtwm_url' =>$mtwm_url,'mtwm_h5' => $mtwm_h5,'mtwm_qrcode' => $mtwm_qrcode);
					}elseif($appid_type == 2){
						//闪购
						$wm = file_get_contents("http://api.tbk.dingdanxia.com/waimai/meituan_sg_privilege", false, $cxContext);
						if($settings['errorcodeid'] == 63){
								var_dump($wm);
							}
						$wm = json_decode($wm,true);
						if($wm['code'] == 200){
							if($settings['poster_type'] == 1 && $type == 1){
								
								$mtsc_url = $wm['data']['we_app_info']['page_path'];
								$mtsc_h5 = $settings['waimaitt_meituansc_tuantext_c'].$wm['data']['h5'];
								$mtsc_qrcode = str_replace(array("http","https"),"https",$wm['data']['we_app_info']['miniCode']);
							}else{
								$mtsc_url = $wm['data']['we_app_info']['page_path'];$mtsc_h5 = '';$mtsc_qrcode = '';
							}
						}else{
							$mtsc_url = '';$mtsc_h5 = '';$mtsc_qrcode = '';
						}
						$backdata = array('mtsc_url' => $mtsc_url,'mtsc_qrcode' =>$mtsc_qrcode,'mtsc_h5' =>$mtsc_h5);
					}
				}
				
				//获取美团推广链接
				$ret = json_encode($backdata);
				$data = array();
				$data["key"] = substr(md5(time() . uniqid()), 0, 16);
				$data["data"] = $this->aesEn($ret, $data["key"]);
				exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
			}elseif($appid_type == 3 || $appid_type == 4){
				//查询是否有pid空闲
				$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
				if($user['relation_id']){//如果用户已经绑定渠道id，则使用渠道id
					$relation_id = $user['relation_id'];
					$pid = explode("_",$settings['tbqudaopid']);
					if($appid_type == 3){
						if($elmwm_act_id){
							$settings['elmwm_promotion_scene_id'] = $elmwm_act_id;
						}else{
							if(!$settings['elmwm_promotion_scene_id']){
								$settings['elmwm_promotion_scene_id'] = '1571715733668';
							}
						}
						$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
						if($settings['errorcodeid'] == 76){
							var_dump($elmwm_url);
						}
						if($elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
							if($settings['poster_type'] == 1){
								$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
							}else{
								$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
							}
							
						}else{
							$backdata = array('elmwm_url' =>'','elmwm_qrcode' =>'','elmwm_h5' =>'','is_qudao' =>1,'pid_time' =>$pid_use_time);
						}
					}elseif($appid_type == 4){
						if(!$settings['elmsc_promotion_scene_id']){$settings['elmsc_promotion_scene_id'] = '1585018034441';}
						$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid[3].'&site_id='.$pid[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&relation_id='.$relation_id.'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
						if($settings['errorcodeid'] == 77){
							var_dump($elmsc_url);
						}
						if($elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
							if($settings['poster_type'] == 1){
								$backdata = array('elmsc_url' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$settings['waimaitt_elmsc_tuantext_c']."：".$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
							}else{
								$backdata = array('elmsc_url' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
							}
							
						}else{
							$backdata = array('elmsc_url' =>'','elmsc_qrcode' =>'','elmsc_h5' =>'','is_qudao' =>1,'pid_time' =>$pid_use_time);
						}
					}
					$ret = json_encode($backdata);
					$data = array();
					$data["key"] = substr(md5(time() . uniqid()), 0, 16);
					$data["data"] = $this->aesEn($ret, $data["key"]);
					exit(json_encode(array('code' => 0, 'status' => 2, 'msg' => 'SUCCESS', 'data' => $data)));
				}else{//如果没有绑定渠道id，则使用pid
					$pid = pdo_get($this->modulename . "_pid", array("openid" => $openid,"is_use" => 1, "uniacid" => $_W["uniacid"]));
					if($pid){$pid_use_time = $pid['use_time'];}
					if(!$pid){
						$pid = pdo_get($this->modulename . "_pid", array("is_use" => 0, "uniacid" => $_W["uniacid"]));
						$pid_use_time = time();
					}
					//有pid空闲
					if($pid){
						pdo_update($this->modulename . "_pid", array("nickname" => $user['nickname'],"openid" => $openid,"unionid" => $user['unionid'],"uid" => $user['user_id'],"is_use" => 1,"use_time" => $pid_use_time,"update_time" => time()), array("id" => $pid['id']));
						pdo_insert($this->modulename . "_pidlog", array("uniacid" => $_W["uniacid"],"pid" => $pid['pid'],"sid" => $pid['sid'],"rid" => $pid['rid'],"nickname" => $user['nickname'],"openid" => $openid,"unionid" => $user['unionid'],"uid" => $user['user_id'],"is_use" => 1,"use_time" => $pid_use_time,"update_time" => time(), "system_id" => $settings['system_id']));
						$pid_array = explode("_",$pid['pid']);
						if($appid_type == 3){
							if($elmwm_act_id){
								$settings['elmwm_promotion_scene_id'] = $elmwm_act_id;
							}else{
								if(!$settings['elmwm_promotion_scene_id']){
									$settings['elmwm_promotion_scene_id'] = '1571715733668';
								}
							}
							if($pid['rid']){
								$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&relation_id='.$pid['rid'].'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
								if($settings['errorcodeid'] == 78){
									var_dump($elmwm_url);
								}
							}else{
								$elmwm_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?appkey='.$settings['appkey'].'&sid='.$pid['sid'].'&adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmwm_promotion_scene_id'].'&platform=2'),true);
								if($settings['errorcodeid'] == 79){
									var_dump($elmwm_url);
								}
							}
							if($elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
								if($settings['poster_type'] == 1){
									$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$settings['waimaitt_elmwm_tuantext_c']."：".$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
								}else{
									$backdata = array('elmwm_url' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmwm_qrcode' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmwm_h5' =>$elmwm_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>1,'pid_time' =>$pid_use_time );
								}
								
							}else{
								$backdata = array('elmwm_url' =>'','elmwm_qrcode' =>'','elmwm_h5' =>'','is_qudao' =>0,'pid_time' =>$pid_use_time);
							}
						}elseif($appid_type == 4){
							if(!$settings['elmsc_promotion_scene_id']){$settings['elmsc_promotion_scene_id'] = '1585018034441';}
							if($pid['rid']){
								$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&relation_id='.$pid['rid'].'&appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&platform=2'),true);
								if($settings['errorcodeid'] == 80){
									var_dump($elmsc_url);
								}
							}else{
								$elmsc_url = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_activitylink_get.ashx?appkey='.$settings['appkey'].'&sid='.$pid['sid'].'&adzone_id='.$pid_array[3].'&site_id='.$pid_array[2].'&promotion_scene_id='.$settings['elmsc_promotion_scene_id'].'&platform=2'),true);
								if($settings['errorcodeid'] == 81){
									var_dump($elmsc_url);
								}
							}
							if($elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url']){
								if($settings['poster_type'] == 1){
									$backdata = array('elmsc_url' => $elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$settings['waimaitt_elmsc_tuantext_c']."：".$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>0,'pid_time' =>$pid_use_time);
								}else{
									$backdata = array('elmsc_url' => $elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_miniprogram_path'],'elmsc_qrcode' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['wx_qrcode_url'],'elmsc_h5' =>$elmsc_url['tbk_sc_activity_info_get_response']['data']['short_click_url'],'is_qudao' =>0,'pid_time' =>$pid_use_time);
								}
								
							}else{
								$backdata = array('elmsc_url' => '','elmsc_qrcode' =>'','elmsc_h5' =>'','is_qudao' =>0,'pid_time' =>$pid_use_time);
							}
						}
						$ret = json_encode($backdata);
						$data = array();
						$data["key"] = substr(md5(time() . uniqid()), 0, 16);
						$data["data"] = $this->aesEn($ret, $data["key"]);
						exit(json_encode(array('code' => 0, 'status' => 2, 'msg' => 'SUCCESS', 'data' => $data)));
					}else{//没有pid空闲，则使用渠道
						$inviter_code = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_sc_invitecode_get.ashx?appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&relation_app=common&code_type=1'),true);
						$inviter_code = $inviter_code['tbk_sc_invitecode_get_response']['data']['inviter_code'];
						$qudao_url = 'https://mos.m.taobao.com/inviter/register?inviterCode='.$inviter_code.'&src=pub&app=common&rtag='.$user['uid'].'A'.time();
						$tkl = json_decode(file_get_contents('https://api.zhetaoke.com:10001/api/open_tkl_create.ashx?appkey='.$settings['appkey'].'&sid='.$settings['sid'].'&url='.urlencode($qudao_url)),true);
						if($settings['errorcodeid'] == 82){
							var_dump($tkl);
						}
						if($tkl['status'] == 200){
							$qudaotkl = $tkl['model'];
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => '3&#55357;&#56392;'.$qudaotkl.'打开&#55357;&#56393;淘bao&#55357;&#56392;或点击链接 https://m.tb.cn/h.aaaaaaa 至浏览器[渠道方备案完成后，可为您进行商品/店铺和更多物料的推广]')));
						}else{
							exit(json_encode(array('code' => 0, 'status' => 0, 'msg' => '获取渠道信息错误')));
						}
					}
				}
			}
		}
		
	
	case "qrcode":
		$uid = intval($_GPC["uid"]);
		$type = trim($_GPC["type"]);
		if (empty($uid)) {
			$ret["poster_url"] = $poster_url;
			$ret = json_encode($ret);
			$data = array();
			$data["key"] = substr(md5(time() . uniqid()), 0, 16);
			$data["data"] = $this->aesEn($ret, $data["key"]);
			exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
		}
		if (empty($type)) {
			$ret["poster_url"] = $poster_url;
			$ret = json_encode($ret);
			$data = array();
			$data["key"] = substr(md5(time() . uniqid()), 0, 16);
			$data["data"] = $this->aesEn($ret, $data["key"]);
			exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
		}
		$is_logofile = "../attachment/".$this->modulename."/".$_W['uniacid']."/".$uid."_".$type."_logo.png";
		if(is_file($is_logofile)){
			$ret["data"] = $_W["siteroot"]."attachment/".$this->modulename."/".$_W['uniacid']."/".$uid."_".$type.".png";
		}else{
			load()->model('mc');
			$account_api = WeAccount::create();
			$token = $account_api->getAccessToken();
			$url = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" . $token;
			$postdata = array("path" => "pages/index/index?uid=" . $uid, "width" => 430);
			$res = ihttp_post($url, json_encode($postdata));
			if($settings['errorcodeid'] == 83){
				var_dump($res);
			}
			$path = "../attachment/".$this->modulename."/".$_W['uniacid'];
			if(!is_dir($path)){
				mkdir(iconv("UTF-8", "GBK", $path),0777,true);
			}
			$qrfile = "../attachment/".$this->modulename."/".$_W['uniacid']."/".$uid."_".$type.".png";
			file_put_contents($qrfile, $res["content"]);
			$logofile = "../attachment/".$this->modulename."/".$_W['uniacid']."/".$uid."_".$type."_logo.png";
			if($type == 'my'){
				$logourl = tomedia($settings['myposterlogo']);
			}else{
				$logourl = $_W["siteroot"] . 'addons/'.$this->modulename.'/qrlogo/'.$type.'.png';
			}
			
			file_put_contents($logofile, file_get_contents($logourl));
			if($type == 'my'){
				$img = $this->imageLiuRound($logofile);
			}else{
				$img = $this->imageLiuRound($logofile);
			}
			imagepng($img, $logofile);
			$im = imagecreatefrompng($logofile);
			$fx = imagesx($im);
			$fy = imagesy($im);
			$logo = imagecreatetruecolor(194, 194);
			imagesavealpha($logo, true);
			$bg = imagecolorallocatealpha($logo, 255, 255, 255, 127);
			imagefill($logo, 0, 0, $bg);
			imagecopyresampled($logo, $im, 0, 0, 0, 0, 194, 194, $fx, $fy);
			imagepng($logo, $logofile);
			$big = imagecreatefromjpeg($qrfile);
			$small = imagecreatefrompng($logofile);
			imagecopy($big, $small, 118, 118, 0, 0, 194, 194);
			imagepng($big, $qrfile);
			imagedestroy($im);
			imagedestroy($small);
			imagedestroy($big);
			$ret["data"] = $_W["siteroot"]."attachment/".$this->modulename."/".$_W['uniacid']."/".$uid."_".$type.".png";
		}
		
		if($this->modulename == 'asterye_huaxcx_plugin_waimai'){$post_modulename = 'asterye_huaxcx_plugin_gzh';}
		if($this->modulename == 'asterye_waimaixia'){$post_modulename = 'asterye_waimaixia_plugin_gzh';}
		$newtime = time()-2592000;
		if($settings['user_poster_keyword'] && $type == 'my'){
			$gzhsettings = pdo_get("uni_account_modules", array("module" => $post_modulename , "uniacid" => $settings['gzh_id']));
            $gzhsettings = unserialize($gzhsettings['settings']);
			$gzh_fans = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings['gzh_id']));
			if($gzh_fans['follow'] == 0){
				$poster_url =  $gzhsettings["followlink"];
			}else{
				$gzh_poster = pdo_get($post_modulename . "_poster", array("keyword" => $settings['user_poster_keyword'], "uniacid" => $settings['gzh_id']));
				$is_poster = pdo_get($post_modulename . "_qr", array("openid" => $gzh_fans['openid'],"createtime >" => $newtime,"posterid" => $gzh_poster['id'], "uniacid" => $settings['gzh_id']));
				if($is_poster){
					$img_path = IA_ROOT."/addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) . "/" . $is_poster['file'];
					if(!is_file($img_path)){
						$poster_url = $_W["siteroot"]."app/index.php?i=".$settings['gzh_id']."&c=entry&m=".$post_modulename."&do=index&op=build&xcx=1&unionid=".$unionid."&content=".urlencode($settings['user_poster_keyword']);
						$poster_url = ihttp_get($poster_url);
						$poster_url = $poster_url["content"];
						if(!$poster_url){
							sleep(2);
							$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						    $poster_url = $gzhimg;
						}
					}else{
						$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						$poster_url = $gzhimg;
					}
				}else{
					$poster_url = $_W["siteroot"]."app/index.php?i=".$settings['gzh_id']."&c=entry&m=".$post_modulename."&do=index&op=build&xcx=1&unionid=".$unionid."&content=".urlencode($settings['user_poster_keyword']);
					$poster_url = ihttp_get($poster_url);
					$poster_url = $poster_url["content"];
					if(!$poster_url){
							sleep(2);
							$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						    $poster_url = $gzhimg;
					}
				}
			}
		}
		if($settings['mtwm_poster_keyword'] && $type == 'mtwm'){
			$gzhsettings = pdo_get("uni_account_modules", array("module" => $post_modulename , "uniacid" => $settings['gzh_id']));
            $gzhsettings = unserialize($gzhsettings['settings']);
			$gzh_fans = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings['gzh_id']));
			if($gzh_fans['follow'] == 0){
				$poster_url =  $gzhsettings["followlink"];
			}else{
				$gzh_poster = pdo_get($post_modulename . "_poster", array("keyword" => $settings['mtwm_poster_keyword'], "uniacid" => $settings['gzh_id']));
				$is_poster = pdo_get($post_modulename . "_qr", array("openid" => $gzh_fans['openid'],"createtime >" => $newtime,"posterid" => $gzh_poster['id'], "uniacid" => $settings['gzh_id']));
				if($is_poster){
					$img_path = IA_ROOT."/addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) . "/" . $is_poster['file'];
					if(!is_file($img_path)){
						$poster_url = $_W["siteroot"]."app/index.php?i=".$settings['gzh_id']."&c=entry&m=".$post_modulename."&do=index&op=build&xcx=1&unionid=".$unionid."&content=".urlencode($settings['mtwm_poster_keyword']);
						$poster_url = ihttp_get($poster_url);
						$poster_url = $poster_url["content"];
						if(!$poster_url){
							sleep(2);
							$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						    $poster_url = $gzhimg;
						}
					}else{
						$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						$poster_url = $gzhimg;
					}
				}else{
					$poster_url = $_W["siteroot"]."app/index.php?i=".$settings['gzh_id']."&c=entry&m=".$post_modulename."&do=index&op=build&xcx=1&unionid=".$unionid."&content=".urlencode($settings['mtwm_poster_keyword']);
					$poster_url = ihttp_get($poster_url);
					$poster_url = $poster_url["content"];
					if(!$poster_url){
							sleep(2);
							$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						    $poster_url = $gzhimg;
						}
				}
			}
		}
		if($settings['mtsc_poster_keyword'] && $type == 'mtsc'){
			$gzhsettings = pdo_get("uni_account_modules", array("module" => $post_modulename , "uniacid" => $settings['gzh_id']));
            $gzhsettings = unserialize($gzhsettings['settings']);
			$gzh_fans = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings['gzh_id']));
			if($gzh_fans['follow'] == 0){
				$poster_url =  $gzhsettings["followlink"];
			}else{
				$gzh_poster = pdo_get($post_modulename . "_poster", array("keyword" => $settings['mtsc_poster_keyword'], "uniacid" => $settings['gzh_id']));
				$is_poster = pdo_get($post_modulename . "_qr", array("openid" => $gzh_fans['openid'],"createtime >" => $newtime,"posterid" => $gzh_poster['id'], "uniacid" => $settings['gzh_id']));
				if($is_poster){
					$img_path = IA_ROOT."/addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) . "/" . $is_poster['file'];
					if(!is_file($img_path)){
						$poster_url = $_W["siteroot"]."app/index.php?i=".$settings['gzh_id']."&c=entry&m=".$post_modulename."&do=index&op=build&xcx=1&unionid=".$unionid."&content=".urlencode($settings['mtsc_poster_keyword']);
						$poster_url = ihttp_get($poster_url);
						$poster_url = $poster_url["content"];
						if(!$poster_url){
							sleep(2);
							$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						    $poster_url = $gzhimg;
						}
					}else{
						$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						$poster_url = $gzhimg;
					}
				}else{
					$poster_url = $_W["siteroot"]."app/index.php?i=".$settings['gzh_id']."&c=entry&m=".$post_modulename."&do=index&op=build&xcx=1&unionid=".$unionid."&content=".urlencode($settings['mtsc_poster_keyword']);
					$poster_url = ihttp_get($poster_url);
					$poster_url = $poster_url["content"];
					if(!$poster_url){
							sleep(2);
							$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						    $poster_url = $gzhimg;
						}
				}
			}
		}
		if($settings['elmwm_poster_keyword'] && $type == 'elmwm'){
			$gzhsettings = pdo_get("uni_account_modules", array("module" => $post_modulename , "uniacid" => $settings['gzh_id']));
            $gzhsettings = unserialize($gzhsettings['settings']);
			$gzh_fans = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings['gzh_id']));
			if($gzh_fans['follow'] == 0){
				$poster_url =  $gzhsettings["followlink"];
			}else{
				$gzh_poster = pdo_get($post_modulename . "_poster", array("keyword" => $settings['elmwm_poster_keyword'], "uniacid" => $settings['gzh_id']));
				$is_poster = pdo_get($post_modulename . "_qr", array("openid" => $gzh_fans['openid'],"createtime >" => $newtime,"posterid" => $gzh_poster['id'], "uniacid" => $settings['gzh_id']));
				if($is_poster){
					$img_path = IA_ROOT."/addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) . "/" . $is_poster['file'];
					if(!is_file($img_path)){
						$poster_url = $_W["siteroot"]."app/index.php?i=".$settings['gzh_id']."&c=entry&m=".$post_modulename."&do=index&op=build&xcx=1&unionid=".$unionid."&content=".urlencode($settings['elmwm_poster_keyword']);
						$poster_url = ihttp_get($poster_url);
						$poster_url = $poster_url["content"];
						if(!$poster_url){
							sleep(2);
							$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						    $poster_url = $gzhimg;
						}
					}else{
						$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						$poster_url = $gzhimg;
					}
				}else{
					$poster_url = $_W["siteroot"]."app/index.php?i=".$settings['gzh_id']."&c=entry&m=".$post_modulename."&do=index&op=build&xcx=1&unionid=".$unionid."&content=".urlencode($settings['elmwm_poster_keyword']);
					$poster_url = ihttp_get($poster_url);
					$poster_url = $poster_url["content"];
					if(!$poster_url){
							sleep(2);
							$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						    $poster_url = $gzhimg;
						}
				}
			}
		}
		if($settings['elmsc_poster_keyword'] && $type == 'elmsc'){
			$gzhsettings = pdo_get("uni_account_modules", array("module" => $post_modulename , "uniacid" => $settings['gzh_id']));
            $gzhsettings = unserialize($gzhsettings['settings']);
			$gzh_fans = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings['gzh_id']));
			if($gzh_fans['follow'] == 0){
				$poster_url =  $gzhsettings["followlink"];
			}else{
				$gzh_poster = pdo_get($post_modulename . "_poster", array("keyword" => $settings['elmsc_poster_keyword'], "uniacid" => $settings['gzh_id']));
				$is_poster = pdo_get($post_modulename . "_qr", array("openid" => $gzh_fans['openid'],"createtime >" => $newtime,"posterid" => $gzh_poster['id'], "uniacid" => $settings['gzh_id']));
				if($is_poster){
					$img_path = IA_ROOT."/addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) . "/" . $is_poster['file'];
					if(!is_file($img_path)){
						$poster_url = $_W["siteroot"]."app/index.php?i=".$settings['gzh_id']."&c=entry&m=".$post_modulename."&do=index&op=build&xcx=1&unionid=".$unionid."&content=".urlencode($settings['elmsc_poster_keyword']);
						$poster_url = ihttp_get($poster_url);
						$poster_url = $poster_url["content"];
						if(!$poster_url){
							sleep(2);
							$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						    $poster_url = $gzhimg;
						}
					}else{
						$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						$poster_url = $gzhimg;
					}
				}else{
					$poster_url = $_W["siteroot"]."app/index.php?i=".$settings['gzh_id']."&c=entry&m=".$post_modulename."&do=index&op=build&xcx=1&unionid=".$unionid."&content=".urlencode($settings['elmsc_poster_keyword']);
					$poster_url = ihttp_get($poster_url);
					$poster_url = $poster_url["content"];
					if(!$poster_url){
							sleep(2);
							$gzhimg = $_W['siteroot'] . "addons/".$post_modulename."/static/data/" . $settings['gzh_id'] . "/" . intval($gzh_poster['id']) .  "/" . $is_poster['file'];
						    $poster_url = $gzhimg;
						}
				}
			}
		}
		if(!$poster_url){
			$poster_url = $_W["siteroot"].'addons/'.$this->modulename.'/qrlogo/elmsc1.png';
		}
		$ret["poster_url"] = $poster_url;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "gzh_poster":
		$ret["data"] = $_W["siteroot"]."attachment/".$this->modulename."/".$_W['uniacid']."/".$uid."_".$type.".png";
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "ad_heng":
		if($settings['system_type'] == 2){
			$condition = "system_id = {$settings['system_id']} AND cateid = 2 AND is_show = 1";
			$orders = " ORDER BY displayorder DESC";
			$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad_u")." WHERE ".$condition.$orders);
		}else{
			$condition = "uniacid = {$_W['uniacid']} AND cateid = 2 AND is_show = 1";
			$orders = " ORDER BY displayorder DESC";
			$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad")." WHERE ".$condition.$orders);
		}
		
		$resArr['code'] = 0;
		$resArr['status'] = 1;
		$resArr['msg'] = 'SUCCESS';
		$resArr['swiperitems'] = array();
		foreach($list as $k=>$v){
			$resArr['ad_heng'][$k] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
		}
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	
	case "waimaidaohang":
		if($settings['system_type'] == 2){
			if($settings['index_type'] == '2'){
				$condition = "system_id = {$settings['system_id']} AND cateid = 11 AND is_show = 1";
			}
			if($settings['index_type'] == '3'){
				$condition = "system_id = {$settings['system_id']} AND cateid = 21 AND is_show = 1";
			}
			if($settings['index_type'] == '4'){
				$condition = "system_id = {$settings['system_id']} AND cateid = 31 AND is_show = 1";
			}
			$orders = " ORDER BY displayorder DESC";
			$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad_u")." WHERE ".$condition.$orders);
		}else{
			if($settings['index_type'] == '2'){
				$condition = "uniacid = {$_W['uniacid']} AND cateid = 11 AND is_show = 1";
			}
			if($settings['index_type'] == '3'){
				$condition = "uniacid = {$_W['uniacid']} AND cateid = 21 AND is_show = 1";
			}
			if($settings['index_type'] == '4'){
				$condition = "uniacid = {$_W['uniacid']} AND cateid = 31 AND is_show = 1";
			}
			$orders = " ORDER BY displayorder DESC";
			$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad")." WHERE ".$condition.$orders);
		}
		
		$resArr['code'] = 0;
		$resArr['status'] = 1;
		$resArr['msg'] = 'SUCCESS';
		$resArr['swiperitems'] = array();
		$i = 0;
		foreach($list as $k=>$v){
			if($v['elmwm_act_id'] == ''){$v['elmwm_act_id'] = 0;}
			if($v['is_ios'] == 1 && $v['elmwm_act_id'] == 0){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 1){
					$resArr['waimaidaohang'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 1){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 1 && $user['parent_id'] > 0){
					$resArr['waimaidaohang'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 2){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 1 && $user['parent_id'] == 0){
					$resArr['waimaidaohang'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}
			if($v['is_ios'] == 2 && $v['elmwm_act_id'] == 0){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 0){
					$resArr['waimaidaohang'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 1){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 0 && $user['parent_id'] > 0){
					$resArr['waimaidaohang'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 2){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 0 && $user['parent_id'] == 0){
					$resArr['waimaidaohang'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}
			if($v['is_ios'] == 0 && $v['elmwm_act_id'] == 0){
				$resArr['waimaidaohang'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
				$i++;
			}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 1){
				if($user['parent_id'] > 0){
					$resArr['waimaidaohang'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 2){
				if($user['parent_id'] == 0){
					$resArr['waimaidaohang'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}
		}
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "tabbar":
		if($settings['system_type'] == 1){
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
		}else{
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W["uniacid"]));
		}
		if($user['is_tuan'] == 0){$cateid = 61;}
		if($user['is_tuan'] == 1){$cateid = 62;}
		if($user['is_tuan'] == 2){$cateid = 63;}
		if(!$openid){$cateid = 61;}
		$condition = "uniacid = {$_W['uniacid']} AND cateid = {$cateid} AND is_show = 1 ";
		$orders = " ORDER BY displayorder DESC";
		$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad")." WHERE ".$condition.$orders);
		$resArr['code'] = 0;
		$resArr['status'] = 1;
		$resArr['msg'] = 'SUCCESS';
		$resArr['swiperitems'] = array();
		$i = 0;
		foreach($list as $k=>$v){
			
			if($v['cateid'] == 61 && $user['is_tuan'] == 0){
				if($v['is_ios'] == 1 && $v['elmwm_act_id'] == 0){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 1){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 1){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 1 && $user['parent_id'] > 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 2){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 1 && $user['parent_id'] == 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}
				if($v['is_ios'] == 2 && $v['elmwm_act_id'] == 0){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 1){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 0 && $user['parent_id'] > 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 2){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 0 && $user['parent_id'] == 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}
				if($v['is_ios'] == 0 && $v['elmwm_act_id'] == 0){
					$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
					$i++;
				}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 1){
					if($user['parent_id'] > 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 2){
					if($user['parent_id'] == 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}
				
			}elseif($v['cateid'] == 62 && $user['is_tuan'] == 1){
				if($v['is_ios'] == 1 && $v['elmwm_act_id'] == 0){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					
					if($user_follow['follow'] == 1){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 1){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 1 && $user['parent_id'] > 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 2){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 1 && $user['parent_id'] == 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}
				if($v['is_ios'] == 2 && $v['elmwm_act_id'] == 0){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 1){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 0 && $user['parent_id'] > 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 2){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 0 && $user['parent_id'] == 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}
				if($v['is_ios'] == 0 && $v['elmwm_act_id'] == 0){
					$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
					$i++;
				}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 1){
					if($user['parent_id'] > 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 2){
					if($user['parent_id'] == 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}
				
			}elseif($v['cateid'] == 63 && $user['is_tuan'] == 2){
				if($v['is_ios'] == 1 && $v['elmwm_act_id'] == 0){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 1){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 1){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 1 && $user['parent_id'] > 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 2){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 1 && $user['parent_id'] == 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}
				if($v['is_ios'] == 2 && $v['elmwm_act_id'] == 0){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 1){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 0 && $user['parent_id'] > 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 2){
					$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
					if($user_follow['follow'] == 0 && $user['parent_id'] == 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}
				if($v['is_ios'] == 0 && $v['elmwm_act_id'] == 0){
					$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
					$i++;
				}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 1){
					if($user['parent_id'] > 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 2){
					if($user['parent_id'] == 0){
						$resArr['tabbar']['list'][$i] = array('key'=>$i,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
						$i++;
					}
				}
				
			}
		}
		$resArr['tabbar']['color'] = $settings['tabbar_color'];
		$resArr['tabbar']['selectedColor'] = $settings['tabbar_selectedColor'];
		$resArr['tabbar']['fontSize'] = $settings['tabbar_fontSize'];
		$resArr['tabbar']['iconWidth'] = $settings['tabbar_iconWidth'];
		$resArr['tabbar']['iconHight'] = $settings['tabbar_iconHight'];
		$resArr['tabbar']['intervalHight'] = $settings['tabbar_intervalHight'];
		$resArr['tabbar']['tabBarHight'] = $settings['tabbar_tabBarHight'];
		$resArr['tabbar']['boxShadow'] = $settings['tabbar_boxShadow'];
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "movietabbar":
		$condition = "uniacid = {$_W['uniacid']} AND cateid = 71 AND is_show = 1 ";
		$orders = " ORDER BY displayorder DESC";
		$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad")." WHERE ".$condition.$orders);
		
		$resArr['code'] = 0;
		$resArr['status'] = 1;
		$resArr['msg'] = 'SUCCESS';
		$resArr['tabbar'] = array();
		foreach($list as $k=>$v){
			$resArr['tabbar']['list'][$k] = array('key'=>$k,'text'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'selectedIconPath'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>tomedia($v['reply_thumb']),'iconPath'=>tomedia($v['waimaitt_list_leftupicon']),'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => tomedia($v['link_thumb']),'link_url' => $v['link_url']);
		}
		$resArr['tabbar']['color'] = $settings['tabbar_color'];
		$resArr['tabbar']['selectedColor'] = $settings['tabbar_selectedColor'];
		$resArr['tabbar']['fontSize'] = $settings['tabbar_fontSize'];
		$resArr['tabbar']['iconWidth'] = $settings['tabbar_iconWidth'];
		$resArr['tabbar']['iconHight'] = $settings['tabbar_iconHight'];
		$resArr['tabbar']['intervalHight'] = $settings['tabbar_intervalHight'];
		$resArr['tabbar']['tabBarHight'] = $settings['tabbar_tabBarHight'];
		$resArr['tabbar']['boxShadow'] = $settings['tabbar_boxShadow'];
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "waimaittdaohang":
		$condition = "uniacid = {$_W['uniacid']} AND cateid = 21 AND is_show = 1";
		$orders = " ORDER BY displayorder DESC";
		$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad")." WHERE ".$condition.$orders);

		$resArr['code'] = 0;
		$resArr['status'] = 1;
		$resArr['msg'] = 'SUCCESS';
		$resArr['swiperitems'] = array();
		foreach($list as $k=>$v){
			if($v['elmwm_act_id'] == ''){$v['elmwm_act_id'] = 0;}
			if($v['is_ios'] == 1 && $v['elmwm_act_id'] == 0){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 1){
					$resArr['waimaidaohang'][$k] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
				}
			}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 1){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 1 && $user['parent_id'] > 0){
					$resArr['waimaidaohang'][$k] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
				}
			}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 2){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 1 && $user['parent_id'] == 0){
					$resArr['waimaidaohang'][$k] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
				}
			}
			if($v['is_ios'] == 2 && $v['elmwm_act_id'] == 0){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 0){
					$resArr['waimaidaohang'][$k] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
				}
			}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 1){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 0 && $user['parent_id'] > 0){
					$resArr['waimaidaohang'][$k] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
				}
			}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 2){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 0 && $user['parent_id'] == 0){
					$resArr['waimaidaohang'][$k] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
				}
			}
			if($v['is_ios'] == 0 && $v['elmwm_act_id'] == 0){
				$resArr['waimaidaohang'][$k] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
			}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 1){
				if($user['parent_id'] > 0){
					$resArr['waimaidaohang'][$k] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
				}
			}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 2){
				if($user['parent_id'] == 0){
					$resArr['waimaidaohang'][$k] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
				}
			}
			
		}
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "jifendaohang":
		if($settings['system_type'] == 2){
			$condition = "system_id = {$settings['system_id']} AND cateid = 51 AND is_show = 1";
			$orders = " ORDER BY displayorder DESC";
			$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad_u")." WHERE ".$condition.$orders);
		}else{
			$condition = "uniacid = {$_W['uniacid']} AND cateid = 51 AND is_show = 1";
			$orders = " ORDER BY displayorder DESC";
			$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad")." WHERE ".$condition.$orders);
		}
		
		$resArr['code'] = 0;
		$resArr['status'] = 1;
		$resArr['msg'] = 'SUCCESS';
		$resArr['swiperitems'] = array();
		foreach($list as $k=>$v){
			$resArr['jifendaohang'][$k] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
		}
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "waimailist":
		if($settings['system_type'] == 2){
			if($settings['index_type'] == '2'){
				$condition = "system_id = {$settings['system_id']} AND cateid = 12 AND is_show = 1";
			}
			if($settings['index_type'] == '3'){
				$condition = "system_id = {$settings['system_id']} AND cateid = 22 AND is_show = 1";
			}
			if($settings['index_type'] == '4'){
				$condition = "system_id = {$settings['system_id']} AND cateid = 32 AND is_show = 1";
			}
			$orders = " ORDER BY displayorder DESC";
			$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad_u")." WHERE ".$condition.$orders);
		}else{
			if($settings['index_type'] == '2'){
				$condition = "uniacid = {$_W['uniacid']} AND cateid = 12 AND is_show = 1";
			}
			if($settings['index_type'] == '3'){
				$condition = "uniacid = {$_W['uniacid']} AND cateid = 22 AND is_show = 1";
			}
			if($settings['index_type'] == '4'){
				$condition = "uniacid = {$_W['uniacid']} AND cateid = 32 AND is_show = 1";
			}
			$orders = " ORDER BY displayorder DESC";
			$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad")." WHERE ".$condition.$orders);
		}
		
		$resArr['code'] = 0;
		$resArr['status'] = 1;
		$resArr['msg'] = 'SUCCESS';
		$resArr['swiperitems'] = array();
		$i = 0;
		foreach($list as $k=>$v){
			if($v['elmwm_act_id'] == ''){$v['elmwm_act_id'] = 0;}
			if($v['is_ios'] == 1 && $v['elmwm_act_id'] == 0){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 1){
					$resArr['waimailist'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'waimaitt_list_bgcolor'=>$v['waimaitt_list_bgcolor'],'waimaitt_list_leftupicon'=>tomedia($v['waimaitt_list_leftupicon']),'waimaitt_list_leftdownicon'=>tomedia($v['waimaitt_list_leftdownicon']),'waimaitt_list_jine'=>$v['waimaitt_list_jine'],'waimaitt_list_jineunit'=>$v['waimaitt_list_jineunit'],'waimaitt_list_jinerighttext'=>$v['waimaitt_list_jinerighttext'],'waimaitt_list_lingqutext'=>$v['waimaitt_list_lingqutext'],'waimaitt_list_lingqucolor'=>$v['waimaitt_list_lingqucolor'],'waimaitt_list_lingqubgcolor'=>$v['waimaitt_list_lingqubgcolor'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 1){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 1 && $user['parent_id'] > 0){
					$resArr['waimailist'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'waimaitt_list_bgcolor'=>$v['waimaitt_list_bgcolor'],'waimaitt_list_leftupicon'=>tomedia($v['waimaitt_list_leftupicon']),'waimaitt_list_leftdownicon'=>tomedia($v['waimaitt_list_leftdownicon']),'waimaitt_list_jine'=>$v['waimaitt_list_jine'],'waimaitt_list_jineunit'=>$v['waimaitt_list_jineunit'],'waimaitt_list_jinerighttext'=>$v['waimaitt_list_jinerighttext'],'waimaitt_list_lingqutext'=>$v['waimaitt_list_lingqutext'],'waimaitt_list_lingqucolor'=>$v['waimaitt_list_lingqucolor'],'waimaitt_list_lingqubgcolor'=>$v['waimaitt_list_lingqubgcolor'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 1 && $v['elmwm_act_id'] == 2){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 1 && $user['parent_id'] == 0){
					$resArr['waimailist'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'waimaitt_list_bgcolor'=>$v['waimaitt_list_bgcolor'],'waimaitt_list_leftupicon'=>tomedia($v['waimaitt_list_leftupicon']),'waimaitt_list_leftdownicon'=>tomedia($v['waimaitt_list_leftdownicon']),'waimaitt_list_jine'=>$v['waimaitt_list_jine'],'waimaitt_list_jineunit'=>$v['waimaitt_list_jineunit'],'waimaitt_list_jinerighttext'=>$v['waimaitt_list_jinerighttext'],'waimaitt_list_lingqutext'=>$v['waimaitt_list_lingqutext'],'waimaitt_list_lingqucolor'=>$v['waimaitt_list_lingqucolor'],'waimaitt_list_lingqubgcolor'=>$v['waimaitt_list_lingqubgcolor'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}
			if($v['is_ios'] == 2 && $v['elmwm_act_id'] == 0){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 0){
					$resArr['waimailist'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'waimaitt_list_bgcolor'=>$v['waimaitt_list_bgcolor'],'waimaitt_list_leftupicon'=>tomedia($v['waimaitt_list_leftupicon']),'waimaitt_list_leftdownicon'=>tomedia($v['waimaitt_list_leftdownicon']),'waimaitt_list_jine'=>$v['waimaitt_list_jine'],'waimaitt_list_jineunit'=>$v['waimaitt_list_jineunit'],'waimaitt_list_jinerighttext'=>$v['waimaitt_list_jinerighttext'],'waimaitt_list_lingqutext'=>$v['waimaitt_list_lingqutext'],'waimaitt_list_lingqucolor'=>$v['waimaitt_list_lingqucolor'],'waimaitt_list_lingqubgcolor'=>$v['waimaitt_list_lingqubgcolor'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 1){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 0 && $user['parent_id'] > 0){
					$resArr['waimailist'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'waimaitt_list_bgcolor'=>$v['waimaitt_list_bgcolor'],'waimaitt_list_leftupicon'=>tomedia($v['waimaitt_list_leftupicon']),'waimaitt_list_leftdownicon'=>tomedia($v['waimaitt_list_leftdownicon']),'waimaitt_list_jine'=>$v['waimaitt_list_jine'],'waimaitt_list_jineunit'=>$v['waimaitt_list_jineunit'],'waimaitt_list_jinerighttext'=>$v['waimaitt_list_jinerighttext'],'waimaitt_list_lingqutext'=>$v['waimaitt_list_lingqutext'],'waimaitt_list_lingqucolor'=>$v['waimaitt_list_lingqucolor'],'waimaitt_list_lingqubgcolor'=>$v['waimaitt_list_lingqubgcolor'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 2 && $v['elmwm_act_id'] == 2){
				$user_follow = pdo_get("mc_mapping_fans", array("unionid" => $unionid, "uniacid" => $settings["gzh_id"]));
				if($user_follow['follow'] == 0 && $user['parent_id'] == 0){
					$resArr['waimailist'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'waimaitt_list_bgcolor'=>$v['waimaitt_list_bgcolor'],'waimaitt_list_leftupicon'=>tomedia($v['waimaitt_list_leftupicon']),'waimaitt_list_leftdownicon'=>tomedia($v['waimaitt_list_leftdownicon']),'waimaitt_list_jine'=>$v['waimaitt_list_jine'],'waimaitt_list_jineunit'=>$v['waimaitt_list_jineunit'],'waimaitt_list_jinerighttext'=>$v['waimaitt_list_jinerighttext'],'waimaitt_list_lingqutext'=>$v['waimaitt_list_lingqutext'],'waimaitt_list_lingqucolor'=>$v['waimaitt_list_lingqucolor'],'waimaitt_list_lingqubgcolor'=>$v['waimaitt_list_lingqubgcolor'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}
			if($v['is_ios'] == 0 && $v['elmwm_act_id'] == 0){
				$resArr['waimailist'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'waimaitt_list_bgcolor'=>$v['waimaitt_list_bgcolor'],'waimaitt_list_leftupicon'=>tomedia($v['waimaitt_list_leftupicon']),'waimaitt_list_leftdownicon'=>tomedia($v['waimaitt_list_leftdownicon']),'waimaitt_list_jine'=>$v['waimaitt_list_jine'],'waimaitt_list_jineunit'=>$v['waimaitt_list_jineunit'],'waimaitt_list_jinerighttext'=>$v['waimaitt_list_jinerighttext'],'waimaitt_list_lingqutext'=>$v['waimaitt_list_lingqutext'],'waimaitt_list_lingqucolor'=>$v['waimaitt_list_lingqucolor'],'waimaitt_list_lingqubgcolor'=>$v['waimaitt_list_lingqubgcolor'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
				$i++;
			}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 1){
				if($user['parent_id'] > 0){
					$resArr['waimailist'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'waimaitt_list_bgcolor'=>$v['waimaitt_list_bgcolor'],'waimaitt_list_leftupicon'=>tomedia($v['waimaitt_list_leftupicon']),'waimaitt_list_leftdownicon'=>tomedia($v['waimaitt_list_leftdownicon']),'waimaitt_list_jine'=>$v['waimaitt_list_jine'],'waimaitt_list_jineunit'=>$v['waimaitt_list_jineunit'],'waimaitt_list_jinerighttext'=>$v['waimaitt_list_jinerighttext'],'waimaitt_list_lingqutext'=>$v['waimaitt_list_lingqutext'],'waimaitt_list_lingqucolor'=>$v['waimaitt_list_lingqucolor'],'waimaitt_list_lingqubgcolor'=>$v['waimaitt_list_lingqubgcolor'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}elseif($v['is_ios'] == 0 && $v['elmwm_act_id'] == 2){
				if($user['parent_id'] == 0){
					$resArr['waimailist'][$i] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'waimaitt_list_bgcolor'=>$v['waimaitt_list_bgcolor'],'waimaitt_list_leftupicon'=>tomedia($v['waimaitt_list_leftupicon']),'waimaitt_list_leftdownicon'=>tomedia($v['waimaitt_list_leftdownicon']),'waimaitt_list_jine'=>$v['waimaitt_list_jine'],'waimaitt_list_jineunit'=>$v['waimaitt_list_jineunit'],'waimaitt_list_jinerighttext'=>$v['waimaitt_list_jinerighttext'],'waimaitt_list_lingqutext'=>$v['waimaitt_list_lingqutext'],'waimaitt_list_lingqucolor'=>$v['waimaitt_list_lingqucolor'],'waimaitt_list_lingqubgcolor'=>$v['waimaitt_list_lingqubgcolor'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
					$i++;
				}
			}
			
		}
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case "waimaittlist":
		if($settings['system_type'] == 2){
			$condition = "system_id = {$settings['system_id']} AND cateid = 22 AND is_show = 1";
			$orders = " ORDER BY displayorder DESC";
			$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad_u")." WHERE ".$condition.$orders);
		}else{
			$condition = "uniacid = {$_W['uniacid']} AND cateid = 22 AND is_show = 1";
			$orders = " ORDER BY displayorder DESC";
			$list = pdo_fetchall("SELECT * FROM ".tablename($this->modulename . "_ad")." WHERE ".$condition.$orders);
		}
		
		$resArr['code'] = 0;
		$resArr['status'] = 1;
		$resArr['msg'] = 'SUCCESS';
		$resArr['swiperitems'] = array();
		foreach($list as $k=>$v){
			$resArr['waimailist'][$k] = array('item_id'=>$v['id'],'bgcolor'=>$v['bgcolor'],'title'=>$v['title'],'title_text'=>$v['title_text'],'title_desc'=>$v['title_desc'],'img'=>tomedia($v['thumb']),'adtype'=>$v['adtype'],'appid_type'=>$v['appid_type'],'appid'=>$v['appid'],'path'=>$v['path'],'url'=>$v['url'],'opentype'=>'click','h5_url'=>$v['url'],'reply_thumb'=>$v['reply_thumb'],'reply_text'=>$v['reply_text'],'link_title' => $v['link_title'],'link_desc' => $v['link_desc'],'link_thumb' => $v['link_thumb'],'link_url' => $v['link_url'],'is_ios'=>$v['is_ios'],'waimaitt_list_bgcolor'=>$v['waimaitt_list_bgcolor'],'waimaitt_list_leftupicon'=>tomedia($v['waimaitt_list_leftupicon']),'waimaitt_list_leftdownicon'=>tomedia($v['waimaitt_list_leftdownicon']),'waimaitt_list_jine'=>$v['waimaitt_list_jine'],'waimaitt_list_jineunit'=>$v['waimaitt_list_jineunit'],'waimaitt_list_jinerighttext'=>$v['waimaitt_list_jinerighttext'],'waimaitt_list_lingqutext'=>$v['waimaitt_list_lingqutext'],'waimaitt_list_lingqucolor'=>$v['waimaitt_list_lingqucolor'],'waimaitt_list_lingqubgcolor'=>$v['waimaitt_list_lingqubgcolor'],'elmwm_act_id'=>$v['elmwm_act_id'],'mtpic'=>$v['mtpic']);
		}
		$ret = array();
		$ret["data"] = $resArr;
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	
	case "ad_kefubind":
		$data['ad_id'] = intval($_GPC["adid"]);
		$data['type'] = trim($_GPC["adtype"]);
		$data['active_time'] = time();
		$kefubind = pdo_get($this->modulename . "_kefubind", array("openid" => $openid));
		if(!$kefubind){
			$data['uniacid'] = $_W["uniacid"];
			$data['openid'] = $openid;
			pdo_insert($this->modulename . "_kefubind", $data);
		}else{
			pdo_update($this->modulename . "_kefubind", $data, array('openid' => $openid));
		}				
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS')));
	
	case 'cash':
		if($settings['system_type'] == 1){
			$num = (double) $_GPC["num"];
			if ($num < 0.1) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "提现额度错误")));
			}
			if ($num < $settings["cash_min"]) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "每次最低" . $settings["cash_min"] . "元")));
			}
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
			if (empty($user)) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "登录失效")));
			}
			if ($user["money"] < $num) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "账户额度不足")));
			}
			if($settings["pay_type"] == 1 && (!$user['alipayno'] || !$user['realname'] || !$user['mobile'])){
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "请填写支付账户/姓名/手机号")));
			}

			$ktime = time()-10;


			$cf = pdo_fetch("SELECT * FROM " . tablename($this->modulename . "_cash_u") . " WHERE unionid = '".$user['unionid']."'  AND create_time > ".$ktime." AND system_id = ".$settings['system_id']);

			if($cf){
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "操作太频繁，请稍后再试")));
			}




			if($settings["pay_type"] == 1){
				$insert = array("unionid" => $user["unionid"],"alipayno" => $user["alipayno"],"realname" => $user["realname"], "uniacid" => $_W['uniacid'], "system_id" => $settings['system_id'], "user_id" => $user["user_id"], "openid" => $openid, "unionid" => $user['unionid'], "num" => $num, "status" => 0, "create_time" => $_W["timestamp"]);
			}else{
				$insert = array("unionid" => $user["unionid"], "uniacid" => $_W['uniacid'], "system_id" => $settings['system_id'], "user_id" => $user["user_id"], "openid" => $openid, "unionid" => $user['unionid'], "num" => $num, "status" => 0, "create_time" => $_W["timestamp"]);
			}
			$result = pdo_insert($this->modulename . "_cash_u", $insert);
			//pdo_debug();die();
			$cash_id = pdo_insertid();
			if ($result) {
				$num = 0 - $num;
				pdo_update($this->modulename . "_user_u", array('money +=' => $num), array("unionid" => $user['unionid'], "system_id" => $settings['system_id']));
				$result = pdo_insert($this->modulename . "_user_logs_u", array("openid" => $user['openid'],"unionid" => $user['unionid'], "system_id" => $settings['system_id'], "uniacid" => $_W['uniacid'],  "num" => $num, "last_num" => $user['money'], "create_time" => $_W["timestamp"], "reason" => '申请提现'));
				
				if($settings["pay_type"] != 1){
					//提现免审
					if($settings["cash_nocheck"] == 1 && -$num <= $settings["cash_nocheck_mini"]){
						$id = $cash_id;
						if (empty($id)) {
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '提现失败')));
						}
						$detail = pdo_fetch("SELECT * FROM " . tablename($this->modulename . "_cash_u") . " WHERE cash_id = '{$id}' AND system_id = {$settings['system_id']}");
						if (empty($detail)) {
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '提现失败')));
						}
						if ($detail["status"] != 0) {
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '该记录已提现')));
						}
						$user = pdo_get($this->modulename . "_user", array("unionid" => $unionid, "uniacid" => $_W["uniacid"]));
						$setting = uni_setting_load("payment", $_W["uniacid"]);
						load()->classs('pay');
						$pay = Pay::create("wechat");
						$params = array();
						$params["mch_appid"] = $_W["account"]["key"];
						$params["mchid"] = $setting["payment"]["wechat"]["mchid"];
						$params["nonce_str"] = strtoupper(md5(date("YmdHis") . mt_rand(10000, 99999)));
						$params["partner_trade_no"] = date("YmdHis") . mt_rand(10000, 99999);
						$params["openid"] = $user["openid"];
						$params["check_name"] = "NO_CHECK";
						$params["amount"] = $detail["num"] * 100;
						$params["desc"] = $settings["cash_in_desc"];
						$params["spbill_create_ip"] = $_W["clientip"];
						$params["sign"] = $pay->bulidSign($params);
						
						if (!file_exists(ATTACHMENT_ROOT . $this->modulename.'/cert/')) {
							mkdir(ATTACHMENT_ROOT . $this->modulename.'/cert/', 511, true);
						}
						$certpath = ATTACHMENT_ROOT . $this->modulename."/cert/" . $_W["uniacid"] . "_" . $config["token"] . "_cert.pem";
						$keypath = ATTACHMENT_ROOT . $this->modulename."/cert/" . $_W["uniacid"] . "_" . $config["token"] . "_key.pem";
						$cert = authcode($setting["payment"]["wechat_refund"]["cert"], "DECODE");
							if (!empty($cert)) {
								file_put_contents($certpath, $cert);
							}
						$key = authcode($setting["payment"]["wechat_refund"]["key"], "DECODE");
							if (!empty($key)) {
								file_put_contents($keypath, $key);
							}
						$result = $pay->requestApi("https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers", $params, array(CURLOPT_SSLCERT => $certpath, CURLOPT_SSLKEY => $keypath));
						if($settings['errorcodeid'] == 84){
							var_dump($result);
						}
						if ($result["result_code"] != "SUCCESS") {
							$log = pdo_insert($this->modulename . "_systemlog", array("api_appKey" => '',"apiname" => '自动提现',"create_time" => $_W["timestamp"], "log" => json_encode($result)));
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '提现失败')));
						} else {
							pdo_update($this->modulename . "_cash_u", array("status" => 1, "billno" => $result["payment_no"]), array("cash_id" => $detail["cash_id"]));
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '提现成功')));
						}
					}else{
						exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '申请成功')));
					}
				}else{
					exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '申请成功')));
				}
				
			}else{
				exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '申请失败')));
			}
		}else{
			$num = (double) $_GPC["num"];
			if ($num < 0.1) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "提现额度错误")));
			}
			if ($num < $settings["cash_min"]) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "每次最低" . $settings["cash_min"] . "元")));
			}
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W['uniacid']));
			if (empty($user)) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "登录失效")));
			}
			if ($user["money"] < $num) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "账户额度不足")));
			}
			if($settings["pay_type"] == 1 && (!$user['alipayno'] || !$user['realname'] || !$user['mobile'])){
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "请填写支付账户/姓名/手机号")));
			}

            $ktime = time()-10;
			$cf = pdo_fetch("SELECT * FROM " . tablename($this->modulename . "_cash") . " WHERE openid = '".$openid."' AND create_time > ".$ktime." AND uniacid = ".$_W['uniacid']);

			if($cf){
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "操作太频繁，请稍后再试")));
			}



			if($settings["pay_type"] == 1){
				$insert = array("uniacid" => $_W['uniacid'],"alipayno" => $user["alipayno"],"realname" => $user["realname"], "user_id" => $user["user_id"], "openid" => $openid, "num" => $num, "status" => 0, "create_time" => $_W["timestamp"]);
			}else{
				$insert = array("uniacid" => $_W['uniacid'], "user_id" => $user["user_id"], "openid" => $openid, "num" => $num, "status" => 0, "create_time" => $_W["timestamp"]);
			}
			
			$result = pdo_insert($this->modulename . "_cash", $insert);
			$cash_id = pdo_insertid();
			if ($result) {
				$num = 0 - $num;
				pdo_update($this->modulename . "_user", array('money +=' => $num), array("user_id" => $user['user_id'],"uniacid" => $_W['uniacid']));
				$result = pdo_insert($this->modulename . "_user_logs", array("user_id" => $user['user_id'],"openid" => $user['openid'],"unionid" => $user['unionid'], "uniacid" => $_W['uniacid'], "num" => $num, "create_time" => $_W["timestamp"], "last_num" => $user['money'], "reason" => '申请提现'));
				if($settings["pay_type"] != 1){
					//提现免审
					if($settings["cash_nocheck"] == 1 && -$num <= $settings["cash_nocheck_mini"]){
						$id = $cash_id;
						if (empty($id)) {
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '提现失败')));
						}
						$detail = pdo_fetch("SELECT * FROM " . tablename($this->modulename . "_cash") . " WHERE cash_id = '{$id}' AND uniacid = {$_W['uniacid']}");
						if (empty($detail)) {
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '提现失败')));
						}
						if ($detail["status"] != 0) {
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '该记录已提现')));
						}
						$user = pdo_get($this->modulename . "_user", array("user_id" => $detail["user_id"]));
						$setting = uni_setting_load("payment", $_W["uniacid"]);
						load()->classs('pay');
						$pay = Pay::create("wechat");
						$params = array();
						$params["mch_appid"] = $_W["account"]["key"];
						$params["mchid"] = $setting["payment"]["wechat"]["mchid"];
						$params["nonce_str"] = strtoupper(md5(date("YmdHis") . mt_rand(10000, 99999)));
						$params["partner_trade_no"] = date("YmdHis") . mt_rand(10000, 99999);
						$params["openid"] = $user["openid"];
						$params["check_name"] = "NO_CHECK";
						$params["amount"] = $detail["num"] * 100;
						$params["desc"] = $settings["cash_in_desc"];
						$params["spbill_create_ip"] = $_W["clientip"];
						$params["sign"] = $pay->bulidSign($params);
						
						if (!file_exists(ATTACHMENT_ROOT . $this->modulename.'/cert/')) {
							mkdir(ATTACHMENT_ROOT . $this->modulename.'/cert/', 511, true);
						}
						$certpath = ATTACHMENT_ROOT . $this->modulename."/cert/" . $_W["uniacid"] . "_" . $config["token"] . "_cert.pem";
						$keypath = ATTACHMENT_ROOT . $this->modulename."/cert/" . $_W["uniacid"] . "_" . $config["token"] . "_key.pem";
						$cert = authcode($setting["payment"]["wechat_refund"]["cert"], "DECODE");
							if (!empty($cert)) {
								file_put_contents($certpath, $cert);
							}
						$key = authcode($setting["payment"]["wechat_refund"]["key"], "DECODE");
							if (!empty($key)) {
								file_put_contents($keypath, $key);
							}
						$result = $pay->requestApi("https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers", $params, array(CURLOPT_SSLCERT => $certpath, CURLOPT_SSLKEY => $keypath));
						if($settings['errorcodeid'] == 85){
							var_dump($result);
						}
						if ($result["result_code"] != "SUCCESS") {
							$log = pdo_insert($this->modulename . "_systemlog", array("api_appKey" => '',"apiname" => '自动提现',"create_time" => $_W["timestamp"], "log" => json_encode($result)));
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '提现失败')));
						} else {
							pdo_update($this->modulename . "_cash", array("status" => 1, "billno" => $result["payment_no"]), array("cash_id" => $detail["cash_id"]));
							exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '提现成功')));
						}
					}else{
						exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '申请成功')));
					}
				}else{
					exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '申请成功')));
				}
				
			}else{
				exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '申请失败')));
			}
		}
		
	
	case 'creditchange':
		if($settings['system_type'] == 1){
			$num = (double) $_GPC["num"];
			if ($num < 0.1) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "兑换不能小于0.1元")));
			}
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
			if (empty($user)) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "登录失效")));
			}
			if ($user["money"] < $num) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "账户额度不足")));
			}


			$ktime = time()-10;
			$cf = pdo_fetch("SELECT * FROM " . tablename($this->modulename . "_user_logs_u") . " WHERE unionid = '".$user['unionid']."' AND create_time > ".$ktime." AND system_id = ".$settings['system_id']);

			if($cf){
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "操作太频繁，请稍后再试")));
			}


			$credit = round($num * $settings['credit_money_rate'],0);
			$num1 = $num;
			$num = 0 - $num;
			pdo_update($this->modulename . "_user_u", array('money +=' => $num,'credit +=' => $credit), array("unionid" => $user['unionid'], "system_id" => $settings['system_id']));
			$result = pdo_insert($this->modulename . "_user_logs_u", array("openid" => $openid,"unionid" => $user['unionid'],"user_id" => $user['user_id'], "system_id" => $settings['system_id'], "uniacid" => $_W['uniacid'],  "num" => $num, "create_time" => $_W["timestamp"], "reason" => '积分兑换', "last_num" => $user['money']));
			$result = pdo_insert($this->modulename . "_user_creditlogs", array("unionid" => $user['unionid'], "openid" => $openid, "user_id" => $user['user_id'], "system_id" => $settings['system_id'], "uniacid" => $_W['uniacid'],  "num" => $credit, "create_time" => $_W["timestamp"], "reason" => $num1.'元兑换'.$credit.'积分', "last_num" => $user['credit']));
			exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '兑换成功')));
		}else{
			$num = (double) $_GPC["num"];
			if ($num < 0.1) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "兑换不能小于0.1元")));
			}
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W['uniacid']));
			if (empty($user)) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "登录失效")));
			}
			if ($user["money"] < $num) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "账户额度不足")));
			}


			$ktime = time()-10;
			$cf = pdo_fetch("SELECT * FROM " . tablename($this->modulename . "_user_logs") . " WHERE openid = '".$openid."' AND create_time > ".$ktime." AND uniacid = ".$_W['uniacid']);

			if($cf){
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "操作太频繁，请稍后再试")));
			}



			$credit = round($num * $settings['credit_money_rate'],0);
			$num1 = $num;
			$num = 0 - $num;
			pdo_update($this->modulename . "_user", array('money +=' => $num,'credit +=' => $credit), array("openid" => $openid));
			$result = pdo_insert($this->modulename . "_user_logs", array("openid" => $openid,"user_id" => $user['user_id'],"unionid" => $user['unionid'], "system_id" => $settings['system_id'], "uniacid" => $_W['uniacid'],  "num" => $num, "create_time" => $_W["timestamp"], "reason" => '积分兑换', "last_num" => $user['money']));
			$result = pdo_insert($this->modulename . "_user_creditlogs", array("unionid" => $user['unionid'], "openid" => $openid, "user_id" => $user['user_id'], "system_id" => $settings['system_id'], "uniacid" => $_W['uniacid'],  "num" => $credit, "create_time" => $_W["timestamp"], "reason" => $num1.'元兑换'.$credit.'积分', "last_num" => $user['credit']));
			exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '兑换成功')));
		}
	case 'logs':
		$pindex = $_GPC["page"];
		$psize = 8;
		if($settings['system_type'] == 1){
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
			$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_user_logs_u") . " WHERE unionid = '{$unionid}' AND system_id = {$settings['system_id']} ORDER BY create_time desc LIMIT " . ($pindex - 1) * $psize . "," . $psize);
			$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_user_logs_u") . " WHERE unionid = '{$unionid}' AND system_id = {$settings['system_id']} ");
		}else{
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W['uniacid']));
			$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_user_logs") . " WHERE user_id = {$user['user_id']} AND uniacid = {$_W['uniacid']} ORDER BY create_time desc LIMIT " . ($pindex - 1) * $psize . "," . $psize);
			$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_user_logs") . " WHERE user_id = {$user['user_id']} AND uniacid = {$_W['uniacid']} ");
		}
		
		foreach ($list as $key => $val) {
			$list[$key]["create_time"] = date("Y-m-d H:i", $val["create_time"]);
		}
		$ret = array();
		$ret["logs"] = $list;
		$ret["total"] = ceil($total / $psize);
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case 'cashlog':
		$pindex = $_GPC["page"];
		$psize = 10;
		if($settings['system_type'] == 1){
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
			$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_cash_u") . " WHERE user_id = {$user['user_id']} AND system_id = {$settings['system_id']} ORDER BY create_time desc LIMIT " . ($pindex - 1) * $psize . "," . $psize);
			$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_cash_u") . " WHERE unionid = {$unionid} AND system_id = {$settings['system_id']} ");
		}else{
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W['uniacid']));
			$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_cash") . " WHERE user_id = {$user['user_id']} AND uniacid = {$_W['uniacid']} ORDER BY create_time desc LIMIT " . ($pindex - 1) * $psize . "," . $psize);
			$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_cash") . " WHERE user_id = {$user['user_id']} AND uniacid = {$_W['uniacid']} ");
		}
		
		foreach ($list as $key => $val) {
			if($val['status'] == 0){
				$list[$key]["status"] = '审核中';
			}
			if($val['status'] == 1){
				$list[$key]["status"] = '提现成功';
			}
			if($val['status'] == 2){
				$list[$key]["status"] = '提现退回';
			}
			$list[$key]["create_time"] = date("Y-m-d H:i", $val["create_time"]);
		}
		$ret = array();
		$ret["logs"] = $list;
		$ret["total"] = ceil($total / $psize);
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case 'creditlog':
		$pindex = $_GPC["page"];
		$psize = 8;
		if($settings['system_type'] == 1){
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
			$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_user_creditlogs") . " WHERE unionid = '{$unionid}' AND system_id = {$settings['system_id']} ORDER BY create_time desc LIMIT " . ($pindex - 1) * $psize . "," . $psize);
			$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_user_creditlogs") . " WHERE unionid = '{$user['unionid']}' AND system_id = {$settings['system_id']} ");
		}else{
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W['uniacid']));
			$list = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . "_user_creditlogs") . " WHERE user_id = {$user['user_id']} AND uniacid = {$_W['uniacid']} ORDER BY create_time desc LIMIT " . ($pindex - 1) * $psize . "," . $psize);
			$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->modulename . "_user_creditlogs") . " WHERE user_id = {$user['user_id']} AND uniacid = {$_W['uniacid']} ");
		}
		
		foreach ($list as $key => $val) {
			$list[$key]["status"] = $val['reason'];
			$list[$key]["create_time"] = date("Y-m-d H:i", $val["create_time"]);
		}
		$ret = array();
		$ret["logs"] = $list;
		$ret["total"] = ceil($total / $psize);
		$ret = json_encode($ret);
		$data = array();
		$data["key"] = substr(md5(time() . uniqid()), 0, 16);
		$data["data"] = $this->aesEn($ret, $data["key"]);
		exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => 'SUCCESS', 'data' => $data)));
	case 'plan':
		$item_id = intval($_GPC["item_id"]);
		if(!$_GPC["userName"] || !$_GPC["provinceName"] || !$_GPC["cityName"] || !$_GPC["detailInfo"] || !$_GPC["telNumber"]){
			exit(json_encode(array("code" => 0, "status" => 0, "msg" => "请填写收货地址信息")));
		}
		$userName = $_GPC["userName"];
		$provinceName = $_GPC["provinceName"];
		$cityName = $_GPC["cityName"];
		$countyName = $_GPC["countyName"];
		$detailInfo = $_GPC["detailInfo"];
		$telNumber = $_GPC["telNumber"];
		if (empty($item_id)) {
			exit(json_encode(array("code" => 0, "status" => 0, "msg" => "参数错误")));
		}
		if($settings['system_type'] == 1){
			$item = pdo_get($this->modulename . "_item", array("item_id" => $item_id, "system_id" => $settings['system_id']));
			if (empty($item)) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "参数错误")));
			}
			if ($item['stock'] == 0) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "库存不足")));
			}
			$user = pdo_get($this->modulename . "_user_u", array("unionid" => $unionid, "system_id" => $settings['system_id']));
			if($item["price"] > 0){
				if ($user["credit"] < $item['price']) {
					exit(json_encode(array("code" => 0, "status" => 0, "msg" => "积分不足")));
				}
			}
			
			if (empty($user)) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "登录失效")));
			}
			if($item["market_price"] == 0 && $item["price"] > 0){//只有积分
				$num = 0 - $item["price"];
				$res = pdo_update($this->modulename . "_user_u", array('credit +=' => $num), array("unionid" => $user['unionid'], "system_id" => $settings['system_id']));
				$result = pdo_insert($this->modulename . "_user_creditlogs", array("unionid" => $user['unionid'], "openid" => $openid, "user_id" => $user['user_id'], "system_id" => $settings['system_id'], "uniacid" => $_W['uniacid'],  "num" => $num,  "last_num" => $user['credit'], "create_time" => $_W["timestamp"], "reason" => '使用'.$item["price"].'积分兑换商品'));
				if($res){
					$order_id = date("YmdHis" . mt_rand(1000, 9999));
					$insert = array("orderid" => $order_id, "unionid" => $unionid, "openid" => $openid, "system_id" => $settings['system_id'],"uniacid" => $_W["uniacid"], "user_id" => $user["user_id"], "item_id" => $item["item_id"], "num" => 1, "pay_type" => 1, "price" => $item["price"], "market_price" => $item["market_price"], "name" => $userName, "mobile" => $telNumber, "address" => $provinceName.$cityName.$countyName.$detailInfo, "is_over" => 0, "create_time" => time());
					$res = pdo_insert($this->modulename . "_item_order", $insert);
					$stock = 0 - 1;
					$res = pdo_update($this->modulename . "_item", array('stock +=' => $stock,'sold +=' => 1), array("item_id" => $item['item_id']));
					exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '兑换成功')));
				}
			}elseif($item["market_price"] > 0){//有金额
				if($item["price"] > 0){
					//$num = 0 - $item["price"];
					//$res = pdo_update($this->modulename . "_user_u", array('credit +=' => $num), array("unionid" => $user['unionid'], "system_id" => $settings['system_id']));
					//$result = pdo_insert($this->modulename . "_user_creditlogs", array("unionid" => $user['unionid'], "openid" => $openid, "user_id" => $user['user_id'], "system_id" => $settings['system_id'], "uniacid" => $_W['uniacid'],  "num" => $num,  "last_num" => $user['credit'], "create_time" => $_W["timestamp"], "reason" => '使用'.$item["price"].'积分兑换商品'));
				}
				$order_id = date("YmdHis" . mt_rand(1000, 9999));
				$insert = array("orderid" => $order_id, "unionid" => $unionid, "openid" => $openid, "system_id" => $settings['system_id'],"uniacid" => $_W["uniacid"], "user_id" => $user["user_id"], "item_id" => $item["item_id"], "num" => 1, "price" => $item["price"], "pay_type" => 2, "market_price" => $item["market_price"], "name" => $userName, "mobile" => $telNumber, "address" => $provinceName.$cityName.$countyName.$detailInfo, "is_over" => 0, "create_time" => time());
				$res = pdo_insert($this->modulename . "_item_order", $insert);
				exit(json_encode(array('code' => 0, 'status' => 2, 'msg' => '兑换成功','order_id' => $order_id)));
			}
		}else{
			$item = pdo_get($this->modulename . "_item", array("item_id" => $item_id, "uniacid" => $_W['uniacid']));
			if (empty($item)) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "参数错误")));
			}
			if ($item['stock'] == 0) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "库存不足")));
			}
			$user = pdo_get($this->modulename . "_user", array("openid" => $openid, "uniacid" => $_W['uniacid']));
			if($item["price"] > 0){
				if ($user["credit"] < $item['price']) {
					exit(json_encode(array("code" => 0, "status" => 0, "msg" => "积分不足")));
				}
			}
			
			if (empty($user)) {
				exit(json_encode(array("code" => 0, "status" => 0, "msg" => "登录失效")));
			}
			if($item["market_price"] == 0 && $item["price"] > 0){//只有积分
				$num = 0 - $item["price"];
				$res = pdo_update($this->modulename . "_user", array('credit +=' => $num), array("openid" => $openid));
				$result = pdo_insert($this->modulename . "_user_creditlogs", array("unionid" => $user['unionid'], "openid" => $openid, "user_id" => $user['user_id'], "system_id" => $settings['system_id'], "uniacid" => $_W['uniacid'],  "num" => $num, "last_num" => $user['credit'],"create_time" => $_W["timestamp"], "reason" => '使用'.$item["price"].'积分兑换商品'));
				if($res){
					$order_id = date("YmdHis" . mt_rand(1000, 9999));
					$insert = array("orderid" => $order_id, "unionid" => $unionid, "openid" => $openid, "system_id" => $settings['system_id'],"uniacid" => $_W["uniacid"], "user_id" => $user["user_id"], "item_id" => $item["item_id"], "num" => 1, "pay_type" => 1, "price" => $item["price"], "market_price" => $item["market_price"], "name" => $userName, "mobile" => $telNumber, "address" => $provinceName.$cityName.$countyName.$detailInfo, "is_over" => 0, "create_time" => time());
					$res = pdo_insert($this->modulename . "_item_order", $insert);
					$stock = 0 - 1;
					$res = pdo_update($this->modulename . "_item", array('stock +=' => $stock,'sold +=' => 1), array("item_id" => $item['item_id']));
				}
				exit(json_encode(array('code' => 0, 'status' => 1, 'msg' => '兑换成功')));
			}elseif($item["market_price"] > 0){//有金额
				if($item["price"] > 0){
					//$num = 0 - $item["price"];
					//$res = pdo_update($this->modulename . "_user", array('credit +=' => $num), array("openid" => $openid));
					//$result = pdo_insert($this->modulename . "_user_creditlogs", array("unionid" => $user['unionid'], "openid" => $openid, "user_id" => $user['user_id'], "system_id" => $settings['system_id'], "uniacid" => $_W['uniacid'],  "num" => $num, "last_num" => $user['credit'],"create_time" => $_W["timestamp"], "reason" => '使用'.$item["price"].'积分兑换商品'));
				}
				$order_id = date("YmdHis" . mt_rand(1000, 9999));
				$insert = array("orderid" => $order_id, "unionid" => $unionid, "openid" => $openid, "system_id" => $settings['system_id'],"uniacid" => $_W["uniacid"], "user_id" => $user["user_id"], "item_id" => $item["item_id"], "num" => 1, "price" => $item["price"], "pay_type" => 2, "market_price" => $item["market_price"], "name" => $userName, "mobile" => $telNumber, "address" => $provinceName.$cityName.$countyName.$detailInfo, "is_over" => 0, "create_time" => time());
				$res = pdo_insert($this->modulename . "_item_order", $insert);
				exit(json_encode(array('code' => 0, 'status' => 2, 'msg' => '兑换成功','order_id' => $order_id)));
			}
			
		}
		
}